You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Either this is a false positive, or evaluation of generated code's forward references is broken -- I really hope it's the former.
Minimal case: repro.py:
from __future__ importannotationsimportattrimporttyping@attr.s(auto_attribs=True)classExample:
blah: typing.Type[int]
Console output:
...
WARNING: Cannot resolve forward reference in type annotations of "repro.Example": name 'typing' is not defined
...
However, the docs still render alright (?) and if you use intersphinx it does work... So, mixed feelings from this. I may have messed up with browser cache or something, try this out and see for yourself.
Note that you can either comment out @attr.s(auto_attribs=True), remove auto_attribs=True (for some reason?), or comment out from __future__ import annotations to get rid of this warning.
I'm new to this whole documentation thing, so I may have missed something though.
The text was updated successfully, but these errors were encountered:
Traceback (most recent call last):
File "C:\Users\A5rocks\Documents\fun\python-tests\docs\source\sphinx_autodoc_typehints.py", line 230, in get_all_type_hints
rv = get_type_hints(obj)
File "C:\Python39\lib\typing.py", line 1442, in get_type_hints
value = _eval_type(value, globalns, localns)
File "C:\Python39\lib\typing.py", line 277, in _eval_type
return t._evaluate(globalns, localns, recursive_guard)
File "C:\Python39\lib\typing.py", line 533, in _evaluate
eval(self.__forward_code__, globalns, localns),
File "<string>", line 1, in <module>
NameError: name 'typing' is not defined
I cannot think of a reason why this would work in one context and not in another....
Okay, so the obj that is erroring is the __init__ method, whereas in my example it's the whole class. Now this is starting to make some sense...
Looks like this is an attrs issue / will be fixed in the next version, whoops! python-attrs/attrs#760
Either this is a false positive, or evaluation of generated code's forward references is broken -- I really hope it's the former.
Minimal case:
repro.py
:Console output:
However, the docs still render alright (?) and if you use intersphinx it does work... So, mixed feelings from this.I may have messed up with browser cache or something, try this out and see for yourself.Note that you can either comment out
@attr.s(auto_attribs=True)
, removeauto_attribs=True
(for some reason?), or comment outfrom __future__ import annotations
to get rid of this warning.I'm new to this whole documentation thing, so I may have missed something though.
The text was updated successfully, but these errors were encountered: