-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Confusing note if Mypy cannot find __init__ of a class #4132
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 has nothing to do with attrs, since mypy knows nothing about it. Minimal repro: class A: pass
A(a=1) |
Well, mypy gives an unhelpful message for both examples - the difference is that my example works at runtime, while yours raises |
And this difference amounts to "mypy knows nothing about attrs" which is a feature request and not this bug. Supporting attrs will not resolve this bug, while handling my example will. |
Most likely we are trying to correct Zac's mental model of how mypy
actually works, and how to understand its error messages. Knowing that mypy
doesn't know what attrs does (in this case, add a __init__ with a different
signature), we can understand that mypy will complain about A(arg=1)
because the __init__ it is aware of does not allow this.
|
The error message for this case has been improved; as of mypy 0.610 it is
|
This is another entry in the genre of confusing interactions between Mypy and attrs, extracted from #2088 by request of @gvanrossum. Let's start with an example:
Mypy can't find
A.__init__
, so it points to the stub forobject.__init__
... but misreports it as the definition ofA
.The text was updated successfully, but these errors were encountered: