Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Closed
Description
Similar to#14002; came up inpython/typeshed#9084.
fromtypingimportTypeVar,Generic,overloadT=TypeVar("T",str,int)classBase(Generic[T]):@overloaddefmethod(self,s:T)->T: ...@overloaddefmethod(self:Base[str],s:bytes)->str: ...defmethod(self,s:object): ...classChild(Base[int]):defmethod(self,s:int)->int:raiseNotImplementedError
(https://mypy-play.net/?mypy=latest&python=3.10&gist=da356a97851f7b7649d208e1359a6de4)
with mypy 1.1.1 produces:
/Users/jelle/bin/inerhit.py:13: error: Signature of "method" incompatible with supertype "Base" [override]/Users/jelle/bin/inerhit.py:13: note: Superclass:/Users/jelle/bin/inerhit.py:13: note: @overload/Users/jelle/bin/inerhit.py:13: note: def method(self, s: int) -> int/Users/jelle/bin/inerhit.py:13: note: @overload/Users/jelle/bin/inerhit.py:13: note: def method(self, s: bytes) -> str/Users/jelle/bin/inerhit.py:13: note: Subclass:/Users/jelle/bin/inerhit.py:13: note: def method(self, s: int) -> intFound 1 error in 1 file (checked 1 source file)There should be no errors. The second overload is not applicable to aBase[int], so it should be fine that the subclass lacks it.