-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
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:
T = TypeVar("T")
A_no_T = TypeVar(
"A_no_T",
bound="A[None]",
)
class A(
Generic[T],
):
@overload
def method(
self: A_no_T,
) -> None:
pass
@overload
def method(
self,
t: T,
) -> None:
pass
def method(
self,
t: Optional[T] = None,
) -> None:
return
class B(A[int]):
def method(
self,
t: int,
) -> None:
passExpected Behavior
The code should typecheck without errors.
Actual Behavior
The following error is raised
Mypy: Signature of "method" incompatible with supertype "A" [override]
Superclass:
@overload
def method(self) -> None
@overload
def method(self, t: int) -> None
Subclass:
def method(self, t: int) -> None
Your Environment
- Mypy version used: 0.931
- Mypy command-line flags: --follow-imports=silent --show-column-numbers --show-error-codes
- Mypy configuration options from
mypy.ini(and other config files):
strict = True
strict_equality = True
implicit_reexport = True - Python version used: 3.8.0
- Operating system and version: Linux Ubuntu 18.04.6 LTS
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong