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

AttributeError Name object has no attribute value #75

Closed
pawamoy opened this issue Nov 11, 2020 · 3 comments
Closed

AttributeError Name object has no attribute value #75

pawamoy opened this issue Nov 11, 2020 · 3 comments
Labels
attributes bug Something isn't working

Comments

@pawamoy
Copy link
Member

pawamoy commented Nov 11, 2020

Describe the bug
Exception while parsing code:

  Traceback (most recent call last):
    File "/home/pawamoy/.cache/pypoetry/virtualenvs/aria2p-h4kgxQkF-py3.9/lib/python3.9/site-packages/pytkdocs/cli.py", line 205, in main
      output = json.dumps(process_json(line))
    File "/home/pawamoy/.cache/pypoetry/virtualenvs/aria2p-h4kgxQkF-py3.9/lib/python3.9/site-packages/pytkdocs/cli.py", line 114, in process_json
      return process_config(json.loads(json_input))
    File "/home/pawamoy/.cache/pypoetry/virtualenvs/aria2p-h4kgxQkF-py3.9/lib/python3.9/site-packages/pytkdocs/cli.py", line 91, in process_config
      obj = loader.get_object_documentation(path, members)
    File "/home/pawamoy/.cache/pypoetry/virtualenvs/aria2p-h4kgxQkF-py3.9/lib/python3.9/site-packages/pytkdocs/loader.py", line 340, in get_object_documentation
      root_object = self.get_module_documentation(leaf, members)
    File "/home/pawamoy/.cache/pypoetry/virtualenvs/aria2p-h4kgxQkF-py3.9/lib/python3.9/site-packages/pytkdocs/loader.py", line 407, in get_module_documentation
      root_object.add_child(self.get_class_documentation(child_node))
    File "/home/pawamoy/.cache/pypoetry/virtualenvs/aria2p-h4kgxQkF-py3.9/lib/python3.9/site-packages/pytkdocs/loader.py", line 442, in get_class_documentation
      attributes_data.update(get_instance_attributes(class_.__init__))
    File "/home/pawamoy/.cache/pypoetry/virtualenvs/aria2p-h4kgxQkF-py3.9/lib/python3.9/site-packages/pytkdocs/parsers/attributes.py", line 155, in get_instance_attributes
      annotation = node_to_annotation(assignment)
    File "/home/pawamoy/.cache/pypoetry/virtualenvs/aria2p-h4kgxQkF-py3.9/lib/python3.9/site-packages/pytkdocs/parsers/attributes.py", line 19, in node_to_annotation
      return f"{node.annotation.value.id}[{node_to_annotation(node.annotation.slice.value)}]"  # type: ignore
  AttributeError: 'Name' object has no attribute 'value'

Seems like ast on Python 3.9 changed a bit.

To Reproduce
I don't know if it's a particular expression/annotation that triggers this, or just a general error due to changes in ast. Needs investigation (first, read Python 3.9 changelog for ast).

Expected behavior
No exception.

System (please complete the following information):

  • pytkdocs version 0.9.0
  • Python version: 3.9.0
  • OS: Linux
@pawamoy pawamoy added attributes bug Something isn't working labels Nov 11, 2020
@tirkarthi
Copy link

This could be due to https://bugs.python.org/issue40430 . Something similar to best-doctor/flake8-annotations-complexity#5

@pawamoy
Copy link
Member Author

pawamoy commented Dec 8, 2020

Thanks for the links @tirkarthi! It does look like a legitimate change in ast. This is really annoying so I'll try to fix this ASAP.

pawamoy added a commit that referenced this issue Dec 8, 2020
It seems `ast` has changed in Python 3.9.
Some objects who previously had a `value` attribute
don't have it anymore.

Issue #73: #73
Issue #75: #75
@pawamoy
Copy link
Member Author

pawamoy commented Jan 3, 2021

Should be fixed in 0.10.1.

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

No branches or pull requests

2 participants