Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnnAssign object has no attribute 'targets' #953

Closed
michaelaye opened this issue Aug 29, 2022 · 4 comments
Closed

AnnAssign object has no attribute 'targets' #953

michaelaye opened this issue Aug 29, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@michaelaye
Copy link
Contributor

michaelaye commented Aug 29, 2022

looks like it's a pure internal reference being wrong? I don't see any of my code being mentioned:

❯ nbdev_export
Traceback (most recent call last):
  File "/luna9/maye/mambaforge/envs/py310/bin/nbdev_export", line 10, in <module>
    sys.exit(nbdev_export())
  File "/luna9/maye/mambaforge/envs/py310/lib/python3.10/site-packages/fastcore/script.py", line 117, in _f
    return tfunc(**merge(args, args_from_prog(func, xtra)))
  File "/luna9/maye/mambaforge/envs/py310/lib/python3.10/site-packages/nbdev/doclinks.py", line 124, in nbdev_export
    for f in files: nb_export(f)
  File "/luna9/maye/mambaforge/envs/py310/lib/python3.10/site-packages/nbdev/export.py", line 59, in nb_export
    mm.make(cells, all_cells, lib_path=lib_path)
  File "/luna9/maye/mambaforge/envs/py310/lib/python3.10/site-packages/nbdev/maker.py", line 193, in make
    _all = self.make_all(all_cells)
  File "/luna9/maye/mambaforge/envs/py310/lib/python3.10/site-packages/nbdev/maker.py", line 108, in make_all
    return retr_exports(L(cells).map(NbCell.parsed_).concat())
  File "/luna9/maye/mambaforge/envs/py310/lib/python3.10/site-packages/nbdev/maker.py", line 95, in retr_exports
    all_assigns = assigns.filter(lambda o: getattr(o.targets[0],'id',None)=='_all_')
  File "/luna9/maye/mambaforge/envs/py310/lib/python3.10/site-packages/fastcore/foundation.py", line 160, in filter
    return self._new(filter_ex(self, f=f, negate=negate, gen=gen, **kwargs))
  File "/luna9/maye/mambaforge/envs/py310/lib/python3.10/site-packages/fastcore/basics.py", line 637, in filter_ex
    return list(res)
  File "/luna9/maye/mambaforge/envs/py310/lib/python3.10/site-packages/nbdev/maker.py", line 95, in <lambda>
    all_assigns = assigns.filter(lambda o: getattr(o.targets[0],'id',None)=='_all_')
AttributeError: 'AnnAssign' object has no attribute 'targets'. Did you mean: 'target'?

version info

❯ mamba list nbdev
# packages in environment at /luna9/maye/mambaforge/envs/py310:
#
# Name                    Version                   Build  Channel
nbdev                     2.2.8                      py_0    fastai

Fastcore is at 1.5.22

@jph00
Copy link
Member

jph00 commented Aug 29, 2022

It's having trouble parsing/understanding your code. Is this a public repo I could look at?

@jph00 jph00 added the bug Something isn't working label Aug 29, 2022
@jph00 jph00 changed the title nbdev_export fails after nbdev_migrate (v2.2.8) AnnAssign object has no attribute 'targets' Aug 29, 2022
@jph00
Copy link
Member

jph00 commented Aug 29, 2022

n/m I see what the problem is. Will fix now.

@jph00 jph00 closed this as completed in d351adc Aug 29, 2022
@michaelaye
Copy link
Contributor Author

i think this line needs that fix as well?

if isinstance(o, _assign_types) and getattr(o.targets[0],'id',None)=='_doc_']

I can PR.

@jalew188
Copy link

jalew188 commented Sep 1, 2022

Thanks @michaelaye . Line 181 should also be changed otherwise it does not work for my code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants