[issue41370] PEP 585 and ForwardRef

Niklas Rosenstein report at bugs.python.org
Tue Jan 25 13:34:14 EST 2022


Niklas Rosenstein <rosensteinniklas at gmail.com> added the comment:

You're right, let me trim it down:

In production we use `get_type_hints()` a lot, expecting it to resolve strings as forward references as per it's original API contract. However, PEP 585 generics parametrized with strings in Python 3.10 doesn't work like that (as the documentation already points out). `get_type_hints()` itself does not fail, subsequently broke our code because it was not built to expect strings in `GenericAlias.__args__`.


What I ask myself is what motivated the decision to change the behaviour for PEP 585 generics in `get_type_hints()` and not go the extra mile.

----------

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


More information about the Python-bugs-list mailing list