Skip to content

gh-137228: Improve get_type_hints() #137230

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented Jul 30, 2025

This fixes the two incorrect behaviors flagged in #137228 and more generally makes get_type_hints() lean more into using the owner concept from annotationlib instead of trying to infer globals and locals namespaces itself.

The previous behavior was copied from earlier typing code. It works around the way
typing.get_type_hints passes its namespaces, but I don't think the behavior is logical
or correct.
This fixes the two incorrect behaviors flagged in python#137228 and more generally
makes get_type_hints() lean more into using the owner concept from annotationlib
instead of trying to infer globals and locals namespaces itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant