bpo-46655: allow stringized TypeAlias with get_type_hints#31156
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a bit weird; it isn't a type, after all. However,
_type_checkis 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_hintscalls 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_checkif 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_hintson a module with a globally definedTypeAlias(that was stringized). See bpo for additional commentary.https://bugs.python.org/issue46655