-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
mypy can't find type defined inside a function. #4349
Comments
Good catch. It appears subclassing NamedTuple is only recognized at the module level, not inside a function. So your workaround would be to move Bar up to the module level. |
...or you can just use (less nice) functional form This means that this bug should be easy to fix. |
My guess is the bug has to do with some pass not descending into function bodies. We've seen such errors before. |
Are there any updates on this? |
This doesn't reproduce in 0.782. Maybe it's already fixed? |
I cannot reproduce it in latest version. Seems it had been fixed. |
Steps to reproduce
mypy can't seem to find a class defined inside a function. For example:
Current behavior
I get the following when I run mypy on the above code (saved in a file named "t1.py"):
t1.py:4: error: Name 'Bar' is not defined
t1.py:7: error: Missing positional arguments "typename", "fields", "verbose", "rename", "kwargs" in call to "Bar"
Expected behavior
No errors or warning from mypy.
mypy --version output
mypy 0.540
The text was updated successfully, but these errors were encountered: