-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Signature of "__call__" incompatible with supertype "type" #6721
Comments
It's a direct consequence of the definition of
The error you are seeing is due to the Liskov principle. (Google it if you're not familiar.) If you really want this signature, just put a |
I think we can actually allow this, as we allow incompatible overrides of On the other hand this is pretty niche, so I am not sure. |
@gvanrossum Thank you for the explanation, after looking at I think that I will actually go with the below code since it seems reasonable and mypy does not raise an error with this signature. class Meta(type):
def __call__(self, *args, value: Optional[int] = None, **kwargs): ... |
Hi,
I found a potential bug where mypy raises an error where it should not. It is present only when user inherits after
type
. Inheritance afterobject
seems to work fine. Please see below code example.Running mypy with command
mypy example.py
results in following output:I would expect mypy to not raise any errors after type checking above code. Adding
#type: ignore
gets rid of an error but it seems that this is a bug in mypy. Unless I'm missing something important?I used
mypy 0.660
andPython 3.7.3
.The text was updated successfully, but these errors were encountered: