-
-
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-normaltopic-type-variables
Description
The following file:
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]):
def x(self) -> T: ...
class B:
def x(self) -> bytes: ...
class C(B, A[bytes]): ...produces
$ mypy samples/doubleinh.py
samples/doubleinh.py:11: error: Definition of "x" in base class "B" is incompatible with definition in base class "A"
with mypy 0.600 and python 3.7.0b4.
This should be accepted because the class inherits from A[bytes], which means that its x method should indeed return bytes. This is only a problem with double inheritance: if I make B inherit from A[bytes], mypy shows no error for B.
My use case was that I wanted to make a typeshed class inherit from both io.BufferedIOBase (to reflect the implementation) and IO[bytes] (to make it compatible with type hints that accept IO[bytes]).
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-normaltopic-type-variables