-
-
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 not flagging subclasses with incompatible constructors #6967
Comments
When a function has no type annotations at all, it's considered untyped, as in this case. If you add a |
Thanks for the response! Ah, that was silly of me to leave out the annotations on the
|
This is actually deliberate decision, mypy specifically whitelists Maybe we can add the stricter checks beyond flag, but OTOH we already have lots of flags. Maybe we can add a selection of stricter checks under the umbrella of |
If we'd add an option for this, I think it would fit better under optional error codes that can enabled (this applies to some existing strictness related flags). This will be possible once we have support for error codes. Since |
Maybe a decorator can be added to
Using |
A decorator is also possible, but IMO having an error code to enable this check using a unified mechanism of enabling error codes would be better in this case. IIRC @JukkaL wanted to add such general mechanism, but it's not clear when we will time to work on this. |
I concur the flag is useful, but I think the decorators would still be a useful addition. |
reproducer
observed behavior
mypy raises no errors, but the code raises a
TypeError
at runtime.expected behavior
pep 484 states:
My understanding of the above is that mypy should be raising an error on the
Bar
definition because its signature is incompatible with that of its superclass. More generally, I tend to be surprised when code that passes mypy raises aTypeError
at runtime.environment
master as of 2019-06-10
Thank you all for an amazing tool!
The text was updated successfully, but these errors were encountered: