-
-
Notifications
You must be signed in to change notification settings - Fork 36
get_type_hints crashes on TypedDict with non-builtin types from other modules #11
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
Comments
This works with cc @ilevkivskyi |
Yep, that fixes it! Thanks! |
This is related to https://bugs.python.org/issue28869. There is a |
I'm seeing what looks like this error without |
@githorse Can you post a detailed example of code that crashes and the full traceback? Also please tell us the exact Python version. |
@gvanrossum Here's a minimal example in Python 3.7.5:
I realize now that I'm only seeing the error when calling |
That's not just a workaround. The docstring for |
We're not going to fix this in mypy-extensions. |
Here's a min repro of the crash:
Here's my understanding of the issue:
When using
from __future__ import annotations
, type annotations becomeForwardRef
s.get_type_hints
resolves these usingglobals
andlocals
. Generally, callingget_type_hints
on a class doesn't requireglobals
orlocals
becauseget_type_hints
retrieves the__dict__
of class's module. However, it seems like, in some cases, the__module__
for TypedDict classes is not set to the module it is defined in, thus whenget_type_hints
tries to resolve the type annotation it fails.This issue does not occur with builtin types because they are always available.
The text was updated successfully, but these errors were encountered: