bpo-28556: typing.get_type_hints: better globalns for classes and modules by ambv · Pull Request #3582 · python/cpython (original) (raw)
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.