@@ -115,7 +115,11 @@ class Base:
115
115
__hash__ = None
116
116
117
117
class 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
119
123
pass
120
124
121
125
# Correct:
@@ -157,7 +161,11 @@ class Base:
157
161
158
162
159
163
class 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
161
169
...
162
170
163
171
@@ -567,11 +575,45 @@ class A:
567
575
568
576
class B(A):
569
577
@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
572
588
@dec
573
589
def h(self) -> str: pass
574
590
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
+
575
617
[case testOverrideStaticMethodWithStaticMethod]
576
618
class A:
577
619
@staticmethod
@@ -4223,11 +4265,12 @@ class A:
4223
4265
def a(self) -> None: pass
4224
4266
b = 1
4225
4267
class 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
4231
4274
4232
4275
[case testVariableProperty]
4233
4276
class A:
@@ -6166,7 +6209,11 @@ import a
6166
6209
[file b.py]
6167
6210
import a
6168
6211
class 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
6170
6217
6171
6218
[file a.py]
6172
6219
import b
@@ -6182,7 +6229,11 @@ import a
6182
6229
import c
6183
6230
class Sub(a.Base):
6184
6231
@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]
6186
6237
6187
6238
[file a.py]
6188
6239
import b
@@ -6204,7 +6255,11 @@ import a
6204
6255
import c
6205
6256
class Sub(a.Base):
6206
6257
@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]
6208
6263
6209
6264
[file a.py]
6210
6265
import b
@@ -7687,13 +7742,29 @@ class Parent:
7687
7742
foobar = TypeVar("foobar")
7688
7743
7689
7744
class 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
7691
7750
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
7693
7756
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
7695
7762
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
7697
7768
return False
7698
7769
7699
7770
x: Parent.foo = lambda: 5
@@ -7761,7 +7832,11 @@ class B:
7761
7832
...
7762
7833
class C(B):
7763
7834
@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
7765
7840
...
7766
7841
[builtins fixtures/property.pyi]
7767
7842
@@ -7771,7 +7846,11 @@ class B:
7771
7846
def foo(self) -> int:
7772
7847
...
7773
7848
class 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
7775
7854
...
7776
7855
[builtins fixtures/property.pyi]
7777
7856
0 commit comments