@@ -147,48 +147,6 @@ class Base:
147
147
class Derived(Base):
148
148
__hash__ = 1 # E: Incompatible types in assignment (expression has type "int", base class "Base" defined the type as "Callable[[Base], int]")
149
149
150
- [case testOverrideCallableAttributeWithMethod]
151
- from typing import Callable
152
-
153
- class Base:
154
- func1: Callable[[str], str]
155
- func2: Callable[[str], str]
156
- func3: Callable[[str], str]
157
-
158
- class Derived(Base):
159
- def func1(self, x: str) -> str:
160
- pass
161
-
162
- @classmethod
163
- def func2(cls, x: str) -> str:
164
- pass
165
-
166
- @staticmethod
167
- def func3(x: str) -> str:
168
- pass
169
- [builtins fixtures/classmethod.pyi]
170
-
171
- [case testOverrideCallableUnionAttributeWithMethod]
172
- from typing import Callable, Union
173
-
174
- class Base:
175
- func1: Union[Callable[[str], str], str]
176
- func2: Union[Callable[[str], str], str]
177
- func3: Union[Callable[[str], str], str]
178
-
179
- class Derived(Base):
180
- def func1(self, x: str) -> str:
181
- pass
182
-
183
- @classmethod
184
- def func2(cls, x: str) -> str:
185
- pass
186
-
187
- @staticmethod
188
- def func3(x: str) -> str:
189
- pass
190
- [builtins fixtures/classmethod.pyi]
191
-
192
150
[case testOverridePartialAttributeWithMethod]
193
151
# This was crashing: https://github.com/python/mypy/issues/11686.
194
152
class Base:
@@ -772,19 +730,6 @@ class B(A):
772
730
pass
773
731
[builtins fixtures/classmethod.pyi]
774
732
775
- [case testOverrideCallableAttributeWithSettableProperty]
776
- from typing import Callable
777
-
778
- class A:
779
- f: Callable[[str], None]
780
-
781
- class B(A):
782
- @property
783
- def f(self) -> Callable[[object], None]: pass
784
- @func.setter
785
- def f(self, x: object) -> None: pass
786
- [builtins fixtures/property.pyi]
787
-
788
733
[case testOverrideCallableAttributeWithMethodMutableOverride]
789
734
# flags: --enable-error-code=mutable-override
790
735
from typing import Callable
@@ -804,6 +749,19 @@ class B(A):
804
749
def f3(x: object) -> None: pass # E: Covariant override of a mutable attribute (base class "A" defined the type as "Callable[[str], None]", override has type "Callable[[object], None]")
805
750
[builtins fixtures/classmethod.pyi]
806
751
752
+ [case testOverrideCallableAttributeWithSettableProperty]
753
+ from typing import Callable
754
+
755
+ class A:
756
+ f: Callable[[str], None]
757
+
758
+ class B(A):
759
+ @property
760
+ def f(self) -> Callable[[object], None]: pass
761
+ @func.setter
762
+ def f(self, x: object) -> None: pass
763
+ [builtins fixtures/property.pyi]
764
+
807
765
[case testOverrideCallableAttributeWithSettablePropertyMutableOverride]
808
766
# flags: --enable-error-code=mutable-override
809
767
from typing import Callable
@@ -818,6 +776,27 @@ class B(A):
818
776
def f(self, x: object) -> None: pass
819
777
[builtins fixtures/property.pyi]
820
778
779
+ [case testOverrideCallableUnionAttributeWithMethod]
780
+ from typing import Callable, Union
781
+
782
+ class Base:
783
+ f1: Union[Callable[[str], str], str]
784
+ f2: Union[Callable[[str], str], str]
785
+ f3: Union[Callable[[str], str], str]
786
+
787
+ class Derived(Base):
788
+ def f1(self, x: str) -> str:
789
+ pass
790
+
791
+ @classmethod
792
+ def f2(cls, x: str) -> str:
793
+ pass
794
+
795
+ @staticmethod
796
+ def f3(x: str) -> str:
797
+ pass
798
+ [builtins fixtures/classmethod.pyi]
799
+
821
800
-- Constructors
822
801
-- ------------
823
802
0 commit comments