You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spurious "incompatible with supertype" error with double inheritance from a generic #5027
$ 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]).
Activity
make http.client.HTTPResponse be a BinaryIO
Make http.client.HTTPResponse a BinaryIO (#2218)
make http.client.HTTPResponse concrete in 3.4
make http.client.HTTPResponse concrete in 3.4 (#2244)
Make http.client.HTTPResponse a BinaryIO (python#2218)
make http.client.HTTPResponse concrete in 3.4 (python#2244)
JelleZijlstra commentedon May 28, 2020
This got fixed somewhere; the sample in my post above now passes mypy. I'm going to close this and remove the related type ignores in typeshed.
remove type ignores about python/mypy#5027
remove type ignores about python/mypy#5027 (#4119)
remove type ignores about python/mypy#5027 (python#4119)