-
-
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
Incompatible signature in method with restricted overload for a generic class #12151
Comments
I don't think that's generally safe. What if the base class x: T
def other_method(self):
self.method(self.x) Now if you call The problem is that when analyzing |
Sorry, but I don't get it. Surely |
Sorry, forget what I said. My analysis was incorrect. I think the issue is that mypy is validating the method implementation signature in the child class against the implementation signature in the parent class, but you want it to take into account the overload signatures in the child class as well. |
Yeah, I think that is something sensible to do. In fact, requiring me to provide the first overload is wrong. |
I think this bug has been fixed. The latest version of mypy (1.5) no longer generates an error. |
I fixed this in #14882 |
Bug Report
When a method of a generic class has an overload for a particular type of the generic parameter, subclasses that don't have that particular value should be able to override the method without that overload, but currently aren't.
To Reproduce
Consider the following code:
Expected Behavior
The code should typecheck without errors.
Actual Behavior
The following error is raised
Your Environment
mypy.ini
(and other config files):strict = True
strict_equality = True
implicit_reexport = True
The text was updated successfully, but these errors were encountered: