-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
bpo-46655: allow stringized TypeAlias with get_type_hints #31156
Conversation
Do we need backports? |
Thanks @GBeauregard for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10. |
Sorry, @GBeauregard and @gvanrossum, I could not cleanly backport this to |
PEP 613 TypeAlias was new in 3.10, so let's backport to 3.10. |
…honGH-31156). (cherry picked from commit 77b025b) Co-authored-by: Gregory Beauregard <greg@greg.red>
GH-31175 is a backport of this pull request to the 3.10 branch. |
This is a bit weird; it isn't a type, after all. However,
_type_check
is called as part of stringized annotation resolution so all valid typeforms need a code path to get through it or we will cause errors forget_type_hints
calls that may not even be intended to inspect the typeform of issue (e.g. called on a module or class). It also needs to be able to pass through_type_check
if you want the typeform to be able to be contained in anAnnotated
(probably not a concern forTypeAlias
).The most reasonable way I currently know to reach this is if you called
get_type_hints
on a module with a globally definedTypeAlias
(that was stringized). See bpo for additional commentary.https://bugs.python.org/issue46655