cpython
cpython copied to clipboard
gh-111353: GenericAlias support and TypeVarLike resolution for `typing.get_type_hints`
get_type_hints
can now resolve TypeVarLikes correctly for all generic classes, including TypedDicts.
There were a lot of edge cases that I tested and subsequently wrote unit tests for.
I've also split some pre-existing code in the typing library into their own utility functions (_copy_with
to work for copying any generic type with new params and _make_substitution
from _GenericAlias._make_substitution
).
I've tried my hardest to document each step but please let me know if there are any steps that don't make sense or could be written another way.
- Issue: gh-111353