@@ -115,7 +115,11 @@ class Base:
115115 __hash__ = None
116116
117117class Derived(Base):
118- def __hash__(self) -> int: # E: Signature of "__hash__" incompatible with supertype "Base"
118+ def __hash__(self) -> int: # E: Signature of "__hash__" incompatible with supertype "Base" \
119+ # N: Superclass: \
120+ # N: None \
121+ # N: Subclass: \
122+ # N: def __hash__(self) -> int
119123 pass
120124
121125# Correct:
@@ -157,7 +161,11 @@ class Base:
157161
158162
159163class Derived(Base):
160- def partial_type(self) -> int: # E: Signature of "partial_type" incompatible with supertype "Base"
164+ def partial_type(self) -> int: # E: Signature of "partial_type" incompatible with supertype "Base" \
165+ # N: Superclass: \
166+ # N: List[Any] \
167+ # N: Subclass: \
168+ # N: def partial_type(self) -> int
161169 ...
162170
163171
@@ -567,11 +575,45 @@ class A:
567575
568576class B(A):
569577 @dec
570- def f(self) -> int: pass # E: Signature of "f" incompatible with supertype "A"
571- def g(self) -> int: pass # E: Signature of "g" incompatible with supertype "A"
578+ def f(self) -> int: pass # E: Signature of "f" incompatible with supertype "A" \
579+ # N: Superclass: \
580+ # N: def f(self) -> str \
581+ # N: Subclass: \
582+ # N: str
583+ def g(self) -> int: pass # E: Signature of "g" incompatible with supertype "A" \
584+ # N: Superclass: \
585+ # N: str \
586+ # N: Subclass: \
587+ # N: def g(self) -> int
572588 @dec
573589 def h(self) -> str: pass
574590
591+ [case testOverrideIncompatibleWithMultipleSupertypes]
592+ class A:
593+ def f(self, *, a: int) -> None:
594+ return
595+
596+ class B(A):
597+ def f(self, *, b: int) -> None: # E: Signature of "f" incompatible with supertype "A" \
598+ # N: Superclass: \
599+ # N: def f(self, *, a: int) -> None \
600+ # N: Subclass: \
601+ # N: def f(self, *, b: int) -> None
602+ return
603+
604+ class C(B):
605+ def f(self, *, c: int) -> None: # E: Signature of "f" incompatible with supertype "B" \
606+ # N: Superclass: \
607+ # N: def f(self, *, b: int) -> None \
608+ # N: Subclass: \
609+ # N: def f(self, *, c: int) -> None \
610+ # E: Signature of "f" incompatible with supertype "A" \
611+ # N: Superclass: \
612+ # N: def f(self, *, a: int) -> None \
613+ # N: Subclass: \
614+ # N: def f(self, *, c: int) -> None
615+ return
616+
575617[case testOverrideStaticMethodWithStaticMethod]
576618class A:
577619 @staticmethod
@@ -4223,11 +4265,12 @@ class A:
42234265 def a(self) -> None: pass
42244266 b = 1
42254267class B(A):
4226- a = 1
4227- def b(self) -> None: pass
4228- [out]
4229- main:5: error: Incompatible types in assignment (expression has type "int", base class "A" defined the type as "Callable[[A], None]")
4230- main:6: error: Signature of "b" incompatible with supertype "A"
4268+ a = 1 # E: Incompatible types in assignment (expression has type "int", base class "A" defined the type as "Callable[[A], None]")
4269+ def b(self) -> None: pass # E: Signature of "b" incompatible with supertype "A" \
4270+ # N: Superclass: \
4271+ # N: int \
4272+ # N: Subclass: \
4273+ # N: def b(self) -> None
42314274
42324275[case testVariableProperty]
42334276class A:
@@ -6166,7 +6209,11 @@ import a
61666209[file b.py]
61676210import a
61686211class Sub(a.Base):
6169- def x(self) -> int: pass # E: Signature of "x" incompatible with supertype "Base"
6212+ def x(self) -> int: pass # E: Signature of "x" incompatible with supertype "Base" \
6213+ # N: Superclass: \
6214+ # N: int \
6215+ # N: Subclass: \
6216+ # N: def x(self) -> int
61706217
61716218[file a.py]
61726219import b
@@ -6182,7 +6229,11 @@ import a
61826229import c
61836230class Sub(a.Base):
61846231 @c.deco
6185- def x(self) -> int: pass # E: Signature of "x" incompatible with supertype "Base"
6232+ def x(self) -> int: pass # E: Signature of "x" incompatible with supertype "Base" \
6233+ # N: Superclass: \
6234+ # N: int \
6235+ # N: Subclass: \
6236+ # N: def x(*Any, **Any) -> Tuple[int, int]
61866237
61876238[file a.py]
61886239import b
@@ -6204,7 +6255,11 @@ import a
62046255import c
62056256class Sub(a.Base):
62066257 @c.deco
6207- def x(self) -> int: pass # E: Signature of "x" incompatible with supertype "Base"
6258+ def x(self) -> int: pass # E: Signature of "x" incompatible with supertype "Base" \
6259+ # N: Superclass: \
6260+ # N: int \
6261+ # N: Subclass: \
6262+ # N: def x(*Any, **Any) -> Tuple[int, int]
62086263
62096264[file a.py]
62106265import b
@@ -7687,13 +7742,29 @@ class Parent:
76877742 foobar = TypeVar("foobar")
76887743
76897744class Child(Parent):
7690- def foo(self, val: int) -> int: # E: Signature of "foo" incompatible with supertype "Parent"
7745+ def foo(self, val: int) -> int: # E: Signature of "foo" incompatible with supertype "Parent" \
7746+ # N: Superclass: \
7747+ # N: None \
7748+ # N: Subclass: \
7749+ # N: def foo(self, val: int) -> int
76917750 return val
7692- def bar(self, val: str) -> str: # E: Signature of "bar" incompatible with supertype "Parent"
7751+ def bar(self, val: str) -> str: # E: Signature of "bar" incompatible with supertype "Parent" \
7752+ # N: Superclass: \
7753+ # N: None \
7754+ # N: Subclass: \
7755+ # N: def bar(self, val: str) -> str
76937756 return val
7694- def baz(self, val: float) -> float: # E: Signature of "baz" incompatible with supertype "Parent"
7757+ def baz(self, val: float) -> float: # E: Signature of "baz" incompatible with supertype "Parent" \
7758+ # N: Superclass: \
7759+ # N: None \
7760+ # N: Subclass: \
7761+ # N: def baz(self, val: float) -> float
76957762 return val
7696- def foobar(self) -> bool: # E: Signature of "foobar" incompatible with supertype "Parent"
7763+ def foobar(self) -> bool: # E: Signature of "foobar" incompatible with supertype "Parent" \
7764+ # N: Superclass: \
7765+ # N: None \
7766+ # N: Subclass: \
7767+ # N: def foobar(self) -> bool
76977768 return False
76987769
76997770x: Parent.foo = lambda: 5
@@ -7761,7 +7832,11 @@ class B:
77617832 ...
77627833class C(B):
77637834 @property
7764- def foo(self) -> int: # E: Signature of "foo" incompatible with supertype "B"
7835+ def foo(self) -> int: # E: Signature of "foo" incompatible with supertype "B" \
7836+ # N: Superclass: \
7837+ # N: def foo(self) -> int \
7838+ # N: Subclass: \
7839+ # N: int
77657840 ...
77667841[builtins fixtures/property.pyi]
77677842
@@ -7771,7 +7846,11 @@ class B:
77717846 def foo(self) -> int:
77727847 ...
77737848class C(B):
7774- def foo(self) -> int: # E: Signature of "foo" incompatible with supertype "B"
7849+ def foo(self) -> int: # E: Signature of "foo" incompatible with supertype "B" \
7850+ # N: Superclass: \
7851+ # N: int \
7852+ # N: Subclass: \
7853+ # N: def foo(self) -> int
77757854 ...
77767855[builtins fixtures/property.pyi]
77777856
0 commit comments