Skip to content

Commit 6448e24

Browse files
committed
update tests
1 parent 1c3dac5 commit 6448e24

File tree

5 files changed

+96
-23
lines changed

5 files changed

+96
-23
lines changed

test-data/unit/check-abstract.test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,11 @@ class A(metaclass=ABCMeta):
790790
def x(self) -> int: pass
791791
class B(A):
792792
@property
793-
def x(self) -> str: return "no" # E: Signature of "x" incompatible with supertype "A"
793+
def x(self) -> str: return "no" # E: Signature of "x" incompatible with supertype "A" \
794+
# N: Superclass: \
795+
# N: int \
796+
# N: Subclass: \
797+
# N: str
794798
b = B()
795799
b.x() # E: "str" not callable
796800
[builtins fixtures/property.pyi]

test-data/unit/check-classes.test

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ class Base:
115115
__hash__ = None
116116

117117
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
119123
pass
120124

121125
# Correct:
@@ -157,7 +161,11 @@ class Base:
157161

158162

159163
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
161169
...
162170

163171

@@ -567,8 +575,16 @@ class A:
567575

568576
class 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

@@ -4223,11 +4239,12 @@ class A:
42234239
def a(self) -> None: pass
42244240
b = 1
42254241
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"
4242+
a = 1 # E: Incompatible types in assignment (expression has type "int", base class "A" defined the type as "Callable[[A], None]")
4243+
def b(self) -> None: pass # E: Signature of "b" incompatible with supertype "A" \
4244+
# N: Superclass: \
4245+
# N: int \
4246+
# N: Subclass: \
4247+
# N: def b(self) -> None
42314248

42324249
[case testVariableProperty]
42334250
class A:
@@ -6166,7 +6183,11 @@ import a
61666183
[file b.py]
61676184
import a
61686185
class Sub(a.Base):
6169-
def x(self) -> int: pass # E: Signature of "x" incompatible with supertype "Base"
6186+
def x(self) -> int: pass # E: Signature of "x" incompatible with supertype "Base" \
6187+
# N: Superclass: \
6188+
# N: int \
6189+
# N: Subclass: \
6190+
# N: def x(self) -> int
61706191

61716192
[file a.py]
61726193
import b
@@ -6182,7 +6203,11 @@ import a
61826203
import c
61836204
class Sub(a.Base):
61846205
@c.deco
6185-
def x(self) -> int: pass # E: Signature of "x" incompatible with supertype "Base"
6206+
def x(self) -> int: pass # E: Signature of "x" incompatible with supertype "Base" \
6207+
# N: Superclass: \
6208+
# N: int \
6209+
# N: Subclass: \
6210+
# N: def x(*Any, **Any) -> Tuple[int, int]
61866211

61876212
[file a.py]
61886213
import b
@@ -6204,7 +6229,11 @@ import a
62046229
import c
62056230
class Sub(a.Base):
62066231
@c.deco
6207-
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]
62086237

62096238
[file a.py]
62106239
import b
@@ -7687,13 +7716,29 @@ class Parent:
76877716
foobar = TypeVar("foobar")
76887717

76897718
class Child(Parent):
7690-
def foo(self, val: int) -> int: # E: Signature of "foo" incompatible with supertype "Parent"
7719+
def foo(self, val: int) -> int: # E: Signature of "foo" incompatible with supertype "Parent" \
7720+
# N: Superclass: \
7721+
# N: None \
7722+
# N: Subclass: \
7723+
# N: def foo(self, val: int) -> int
76917724
return val
7692-
def bar(self, val: str) -> str: # E: Signature of "bar" incompatible with supertype "Parent"
7725+
def bar(self, val: str) -> str: # E: Signature of "bar" incompatible with supertype "Parent" \
7726+
# N: Superclass: \
7727+
# N: None \
7728+
# N: Subclass: \
7729+
# N: def bar(self, val: str) -> str
76937730
return val
7694-
def baz(self, val: float) -> float: # E: Signature of "baz" incompatible with supertype "Parent"
7731+
def baz(self, val: float) -> float: # E: Signature of "baz" incompatible with supertype "Parent" \
7732+
# N: Superclass: \
7733+
# N: None \
7734+
# N: Subclass: \
7735+
# N: def baz(self, val: float) -> float
76957736
return val
7696-
def foobar(self) -> bool: # E: Signature of "foobar" incompatible with supertype "Parent"
7737+
def foobar(self) -> bool: # E: Signature of "foobar" incompatible with supertype "Parent" \
7738+
# N: Superclass: \
7739+
# N: None \
7740+
# N: Subclass: \
7741+
# N: def foobar(self) -> bool
76977742
return False
76987743

76997744
x: Parent.foo = lambda: 5
@@ -7761,7 +7806,11 @@ class B:
77617806
...
77627807
class C(B):
77637808
@property
7764-
def foo(self) -> int: # E: Signature of "foo" incompatible with supertype "B"
7809+
def foo(self) -> int: # E: Signature of "foo" incompatible with supertype "B" \
7810+
# N: Superclass: \
7811+
# N: def foo(self) -> int \
7812+
# N: Subclass: \
7813+
# N: int
77657814
...
77667815
[builtins fixtures/property.pyi]
77677816

@@ -7771,7 +7820,11 @@ class B:
77717820
def foo(self) -> int:
77727821
...
77737822
class C(B):
7774-
def foo(self) -> int: # E: Signature of "foo" incompatible with supertype "B"
7823+
def foo(self) -> int: # E: Signature of "foo" incompatible with supertype "B" \
7824+
# N: Superclass: \
7825+
# N: int \
7826+
# N: Subclass: \
7827+
# N: def foo(self) -> int
77757828
...
77767829
[builtins fixtures/property.pyi]
77777830

test-data/unit/check-dataclasses.test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,11 @@ class Base:
198198
@dataclass
199199
class BadDerived1(Base):
200200
def foo(self) -> int: # E: Dataclass attribute may only be overridden by another attribute \
201-
# E: Signature of "foo" incompatible with supertype "Base"
201+
# E: Signature of "foo" incompatible with supertype "Base" \
202+
# N: Superclass: \
203+
# N: int \
204+
# N: Subclass: \
205+
# N: def foo(self) -> int
202206
return 1
203207

204208
@dataclass

test-data/unit/check-functions.test

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,7 +2848,11 @@ class C(A): # inverted order of decorators
28482848
class D(A):
28492849
@property
28502850
@override
2851-
def f(self) -> int: pass # E: Signature of "f" incompatible with supertype "A"
2851+
def f(self) -> int: pass # E: Signature of "f" incompatible with supertype "A" \
2852+
# N: Superclass: \
2853+
# N: str \
2854+
# N: Subclass: \
2855+
# N: int
28522856
[builtins fixtures/property.pyi]
28532857
[typing fixtures/typing-full.pyi]
28542858

@@ -2877,7 +2881,11 @@ class C(A):
28772881
def f(self, value: str) -> None: pass
28782882

28792883
class D(A):
2880-
@override # E: Signature of "f" incompatible with supertype "A"
2884+
@override # E: Signature of "f" incompatible with supertype "A" \
2885+
# N: Superclass: \
2886+
# N: str \
2887+
# N: Subclass: \
2888+
# N: int
28812889
@property
28822890
def f(self) -> int: pass
28832891

test-data/unit/check-plugin-attrs.test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,11 @@ class Sub(Base):
18771877
last_name: str
18781878

18791879
@property
1880-
def name(self) -> int: ... # E: Signature of "name" incompatible with supertype "Base"
1880+
def name(self) -> int: ... # E: Signature of "name" incompatible with supertype "Base" \
1881+
# N: Superclass: \
1882+
# N: str \
1883+
# N: Subclass: \
1884+
# N: int
18811885

18821886
# This matches runtime semantics
18831887
reveal_type(Sub) # N: Revealed type is "def (*, name: builtins.str, first_name: builtins.str, last_name: builtins.str) -> __main__.Sub"

0 commit comments

Comments
 (0)