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
Copy file name to clipboardExpand all lines: test-data/unit/check-classes.test
+27-9Lines changed: 27 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -784,7 +784,7 @@ class A:
784
784
f: Callable[[str], None]
785
785
786
786
class B(A):
787
-
@property # E: Covariant override of a mutable attribute (base class "A" defined the type as "Callable[[str], None]", override has type "Callable[[object], None]")
787
+
@property
788
788
def f(self) -> Callable[[object], None]: pass
789
789
@func.setter
790
790
def f(self, x: object) -> None: pass
@@ -8087,7 +8087,10 @@ class B2:
8087
8087
class C2(B2):
8088
8088
@property
8089
8089
def foo(self) -> str: ...
8090
-
@foo.setter
8090
+
@foo.setter # E: Incompatible override of a setter type \
8091
+
# N: (base class "B2" defined the type as "B", \
8092
+
# N: override has type "C") \
8093
+
# N: Setter types should behave contravariantly
8091
8094
def foo(self, x: C) -> None: ...
8092
8095
8093
8096
class B3:
@@ -8109,7 +8112,10 @@ class B4:
8109
8112
class C4(B4):
8110
8113
@property
8111
8114
def foo(self) -> C: ...
8112
-
@foo.setter
8115
+
@foo.setter # E: Incompatible override of a setter type \
8116
+
# N: (base class "B4" defined the type as "B", \
8117
+
# N: override has type "C") \
8118
+
# N: Setter types should behave contravariantly
8113
8119
def foo(self, x: C) -> None: ...
8114
8120
8115
8121
class B5:
@@ -8118,10 +8124,16 @@ class B5:
8118
8124
@foo.setter
8119
8125
def foo(self, x: B) -> None: ...
8120
8126
class C5(B5):
8121
-
@property
8127
+
@property # E: Signature of "foo" incompatible with supertype "B5" \
8128
+
# N: Superclass: \
8129
+
# N: str \
8130
+
# N: Subclass: \
8131
+
# N: C
8122
8132
def foo(self) -> C: ...
8123
-
@foo.setter
8124
-
def foo(self, x: C) -> None: ...
8133
+
@foo.setter # E: Incompatible override of a setter type \
8134
+
# N: (base class "B5" defined the type as "B", \
8135
+
# N: override has type "str")
8136
+
def foo(self, x: str) -> None: ...
8125
8137
8126
8138
class B6:
8127
8139
@property
@@ -8144,12 +8156,15 @@ class B1:
8144
8156
class C1(B1):
8145
8157
@property
8146
8158
def foo(self) -> B: ...
8147
-
@foo.setter
8159
+
@foo.setter # E: Incompatible override of a setter type \
8160
+
# N: (base class "B1" defined the type as "B", \
8161
+
# N: override has type "C") \
8162
+
# N: Setter types should behave contravariantly
8148
8163
def foo(self, x: C) -> None: ...
8149
8164
8150
8165
class B2:
8151
8166
foo: C
8152
-
class C2(2):
8167
+
class C2(B2):
8153
8168
@property
8154
8169
def foo(self) -> C: ...
8155
8170
@foo.setter
@@ -8190,7 +8205,10 @@ class B3:
8190
8205
@foo.setter
8191
8206
def foo(self, x: B) -> None: ...
8192
8207
class C3(B3):
8193
-
foo: C
8208
+
foo: C # E: Incompatible override of a setter type \
0 commit comments