-
Notifications
You must be signed in to change notification settings - Fork 233
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
Typed NamedTuple with member function generating another instance of class fails at runtime with NameError #485
Comments
This is because the name |
Thanks for the tip! Interesting. So, the name |
Methods are part of the class body. So this also will not work class Example:
def test(a: Example):
pass nor this class Example:
def test(a) -> Example:
pass However, the same use of quotes can be used. |
huh. Cool. Definitely good to know. Thanks a lot @ethanhs! |
I do think there's a mypy bug here -- outside stubs, this should be rejected. |
Yes, and we already have a mypy issue about this (python/mypy#948). |
...or PEP 563 can be accepted :-) |
I simplified the code just for proof of concept:
While
mypy
doesn't complain at this, the python interpreter crashes with aNameError
saying:Unfortunately, I dropped the return type annotation as a result (which mypy didn't complain about) in order to make it runnable.
The text was updated successfully, but these errors were encountered: