-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add backport of evaluate_forward_ref
#497
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Jelle Zijlstra <[email protected]>
evalaute_forward_ref
evaluate_forward_ref
restructuring & comments
Co-authored-by: Jelle Zijlstra <[email protected]>
SOURCE = 3 | ||
STRING = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess, SOURCE
will be removed soon?
if _FORWARD_REF_HAS_CLASS | ||
else Final # will not raise error in older versions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if Final
should throw errors in earlier versions that do not implement __forward_is_class__
# Assure that these are not in globals | ||
assert X.__name__ not in globals() | ||
assert Y.__name__ not in globals() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These asserts are important for test design; should I use self.assertNotIn
instead?
Backports
evaluate_forward_ref
from JelleZijlstra's PR python/cpython#119891 / PEP 749.The most tricky part seems to be in recursive
ForwardRef
s, 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
python/cpython@079875e39