-
-
Notifications
You must be signed in to change notification settings - Fork 111
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]>
src/typing_extensions.py
Outdated
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?
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.
We should just remove SOURCE since we never released this enum.
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 wonder if the name change & doc changes should possible addressed by another PR
src/typing_extensions.py
Outdated
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.
We should just remove SOURCE since we never released this enum.
src/test_typing_extensions.py
Outdated
localns, | ||
type_params, | ||
owner, | ||
) in unroll_cases(cases, locals()): |
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'm not sure all this indirection makes the test cases better. It becomes harder to verify the tests behave as expected with so much logic between the definition of the tests and the actual tests.
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 share that sentiment. I did some reordering to bring the actual test and case definition closer together, but it does not reduce the overall code in that function.
So far I do not see a good way how to simplify it in a nice way. If you/anyone has suggestions on how to restructure / parts to remove I am open for it.
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'd simply write explicit test cases for some important cases, instead of attempting to create an abstraction around them.
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.
Done, Yes I think that looks better now. Thank you.
See PEP 749
…rd_ref' into 3.14/evaluate_forward_ref
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