-
-
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
“Duplicate base class” blocks checking #15349
Comments
@xiaxinmeng I believe mypy is correct in this case because when class D is constructed, since it inherits two instances of class B, when an attribute or method of class N is invoked from an instance of class D, Python does not know which instance of class N should be called. I believe this issue can be worked around by removing the "metaclass=N" argument from class B |
I think that this is a correct thing to do:
>>> class A: ...
...
>>> class B(A, A): ...
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: duplicate base class A So, you app won't work and mypy catches that.
|
Can't we make it inherit from Any or ignore the second base? I feel we should strongly avoid blocking errors if possible. |
We can still inherit from one of them, I guess. I will take a look and send a PR. |
Continue type checking if a class has two or more identical bases. Closes #15349 --------- Co-authored-by: hauntsaninja <[email protected]>
The duplicate base class causes the checking blocked.
example.py
The expected behavior:
The error can be ignored and the checking will not be blocked.
The actual behavior:
Environment
Mypy version: 1.3.0
Python version: 3.11.3
Operating System: Ubuntu 18.04
How to install MyPy: "python3.11 -m pip install mypy"
The text was updated successfully, but these errors were encountered: