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

get_annotation_class_name() not always returning string #145

Closed

Conversation

wlupton
Copy link

@wlupton wlupton commented Jun 6, 2020

Under python3.8 I get the following crash:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/sphinx/events.py", line 110, in emit
    results.append(listener.handler(self.app, *args))
  File "/usr/local/lib/python3.8/dist-packages/sphinx_autodoc_typehints.py", line 374, in process_docstring
    formatted_annotation = format_annotation(
  File "/usr/local/lib/python3.8/dist-packages/sphinx_autodoc_typehints.py", line 146, in format_annotation
    formatted_args = args_format.format(', '.join(format_annotation(arg, fully_qualified)
  File "/usr/local/lib/python3.8/dist-packages/sphinx_autodoc_typehints.py", line 146, in <genexpr>
    formatted_args = args_format.format(', '.join(format_annotation(arg, fully_qualified)
  File "/usr/local/lib/python3.8/dist-packages/sphinx_autodoc_typehints.py", line 117, in format_annotation
    args = get_annotation_args(annotation, module, class_name)
  File "/usr/local/lib/python3.8/dist-packages/sphinx_autodoc_typehints.py", line 63, in get_annotation_args
    original = getattr(sys.modules[module], class_name)
TypeError: getattr(): attribute name must be string

I didn't get this under python 3.6 so I guess something changed between python 3.6 and 3.8?

It seems that get_annotation_class_name() isn't always returning a string? I added the code shown in the PR (an avoidance measure, not a fix) and now get this:

annotation typing.IO[str] module 'typing' class_name <property object at 0x7fb1c74402c0> <class 'property'>

This is coming (not surprisingly) from this in my python code:

dumpfd: IO[str]

Sorry, but I haven't narrowed it down further (as yet).

@agronholm
Copy link
Collaborator

This particular case was not caught by the test suite but the fix proposed here is not the right one in my opinion. I will fix the issue but I will have to turn down this PR, sorry.

@agronholm agronholm closed this Jun 7, 2020
@wlupton
Copy link
Author

wlupton commented Jun 8, 2020

Of course! I didn't think this was the fix; it was the workaround that would (I hope) help to illustrate and narrow down the problem. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants