python / typing_extensions

Backported and experimental type hints for Python
Other
446 stars 110 forks source link

Add backport of `evaluate_forward_ref` #497

Open Daraan opened 3 weeks ago

Daraan commented 3 weeks ago

Backports evaluate_forward_ref from JelleZijlstra's PR https://github.com/python/cpython/pull/119891 / PEP 749.

The most tricky part seems to be in recursive ForwardRefs, at least in my tests they worked better in 3.9 and but not in 3.8 and 3.10. If someone has some nice examples how to break it I gladly add them. Limitation has been added to the docs.

Tests are also tested against cpython main https://github.com/python/cpython/commit/079875e39