Skip to content

[3.6] bpo-28556: typing.get_type_hints: better globalns for classes and modules (GH-3582) #3583

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

Merged
merged 1 commit into from
Sep 14, 2017

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Sep 14, 2017

This makes the default behavior (without specifying globalns manually) more
predictable for users, finds the right globalns automatically.

Implementation for classes assumes has a __module__ attribute and that module
is present in sys.modules. It does this recursively for all bases in the
MRO. For modules, the implementation just uses their __dict__ directly.

This is backwards compatible, will just raise fewer exceptions in naive user
code.

Originally implemented and reviewed at python/typing#470.
(cherry picked from commit f350a26)

https://bugs.python.org/issue28556

…nd modules (pythonGH-3582)

This makes the default behavior (without specifying `globalns` manually) more
predictable for users, finds the right globalns automatically.

Implementation for classes assumes has a `__module__` attribute and that module
is present in `sys.modules`.  It does this recursively for all bases in the
MRO.  For modules, the implementation just uses their `__dict__` directly.

This is backwards compatible, will just raise fewer exceptions in naive user
code.

Originally implemented and reviewed at python/typing#470.
(cherry picked from commit f350a26)
@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

Thanks again to your contribution and we look forward to looking at it!

@ambv ambv merged commit 1658ec0 into python:3.6 Sep 14, 2017
@miss-islington
Copy link
Contributor Author

Thanks, @ambv!

@miss-islington miss-islington deleted the backport-f350a26-3.6 branch September 14, 2017 20:52
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.

5 participants