-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normal
Description
Actual example of this code can be found in Python 3.6's enum with Flag and IntFlag.
Minimal repro::
from typing import TypeVar
_T = TypeVar('_T')
class Base:
def __or__(self: _T, other: _T) -> _T: ...
def __and__(self: _T, other: _T) -> _T: ...
def __xor__(self: _T, other: _T) -> _T: ...
class Other(int, Base): # <-- errors here
def __or__(self: _T, other: Union[int, _T]) -> _T: ... # type: ignore
def __and__(self: _T, other: Union[int, _T]) -> _T: ... # type: ignore
def __xor__(self: _T, other: Union[int, _T]) -> _T: ... # type: ignoreExpected behavior: no errors.
Actual behavior:
f:11: error: Definition of "__and__" in base class "int" is incompatible with definition in base class "Base"
f:11: error: Definition of "__or__" in base class "int" is incompatible with definition in base class "Base"
f:11: error: Definition of "__xor__" in base class "int" is incompatible with definition in base class "Base"
The errors would be fine if Other didn't redefine the methods itself. In this case the incompatibility in base classes is irrelevant.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normal