AttributeError Name object has no attribute value
pawamoy opened this issue · comments
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
This could be due to https://bugs.python.org/issue40430 . Something similar to best-doctor/flake8-annotations-complexity#5
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.
Should be fixed in 0.10.1.