-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Type alias fails but long version works. #10139
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
I think the issue here is that mypy doesn't know what I'm not familiar with |
I'm not sure how it works either @JelleZijlstra but I know it shows up in my IDE as a class. You can kind of see it in my screen shot as @jeshan can you provide some insight if you have time? |
@shadycuz I never used mypy and don't know how it works so I'm not sure I can be of help here. Appreciate if you can point me in the right direction. Can you try reproducing the issue with type hints from some other package? The way I generate code is nested classes, i.e If other packages work, then this issue should be moved to https://github.com/jeshan/botostubs/issues Or maybe the real resolution is in #9404 |
@jeshan Okay, just checking. If its just a class it should work fine with mypy. |
FWIW, this works fine in pyright, so it's likely a bug in mypy. The botostubs file is very large (150K lines long — appears to be auto-generated), so perhaps that's contributing to the issue. |
Yeah I should work on that some day! But Levi wrote that at least the long form works. So, that doesn't seem to be the right explanation as mypy definitely knows about the types. |
@shadycuz This works for me, using the latest mypy development version and mypy 0.812. What version of botostubs are you using, and have you installed it in the same environment as mypy? For example, can you give the output of |
botostubs and mypy are in the same environment. I'm not sure if its the way mypy does versions but poetry wont update it.
|
@JukkaL That got me playing around and trying stuff and I found the issue. I don't actually run my tests in poetry's shell, I use nox. When I run nox I only install dev dependencies. So botostubs was not getting installed. Now that I fixed that the error is gone 🎉 I also updated to 0.812 and it looks like it has additional checks because now I have more errors about other parts of my code 😊 Thanks |
Bug Report
mypy fails when an alias is used but not when the long form is used
To Reproduce
Expected Behavior
I expected that I would be able to use the type alias. When I use the long form.
I do not get the error when I run mypy
Actual Behavior
It errors when using the alias.
Your Environment
mypy.ini
(and other config files):Not sure if it means anything but my IDE (visual studio code with pylance) works with the alias:
The text was updated successfully, but these errors were encountered: