[issue43646] ForwardRef name conflict during evaluation

Ken Jin report at bugs.python.org
Tue Apr 13 06:05:17 EDT 2021


Ken Jin <kenjin4096 at gmail.com> added the comment:

@tefra, now that issue42904 has been solved, can you test your code again with 3.10.0a8? (it's not out yet, so you may have to pull the code from CPython's GitHub master branch and build CPython)

Running your code again, it seems to be fixed:

Python 3.10.0a7+
>>> from typing import get_type_hints, Optional
>>> from a import Root as RootA, Person as PersonA
>>> from b import Root as RootB, Person as PersonB
>>> roota_hints = get_type_hints(RootA)
>>> rootb_hints = get_type_hints(RootB)
>>> print(roota_hints)
{'a': typing.List[a.Person]}
>>> print(rootb_hints)
{'b': typing.List[b.Person]}

However, it's still around for 3.9 and below if I use string annotations in classes. There's some discussion in that issue about why it may not be backported though.

----------
status: open -> pending

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43646>
_______________________________________


More information about the Python-bugs-list mailing list