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
Emit [mutable-override] for covariant override of attribute with method (#18058)
Fixes#18052
Given:
```python
# flags: --enable-error-code=mutable-override
from typing import Callable
class Parent:
func: Callable[[str], None]
class Child(Parent):
def func(self, x: object) -> None: pass
```
Before:
```
Success: no issues found in 1 source file
```
After:
```
main.py:7 error: Covariant override of a mutable attribute (base class "Parent" defined the type as "Callable[[str], None]", override has type "Callable[[object], None]")
Found 1 error in 1 file (checked 1 source file)
```
def f1(self, 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]")
758
+
759
+
@classmethod
760
+
def f2(cls, 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]")
761
+
762
+
@staticmethod
763
+
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]")
@property # E: Covariant override of a mutable attribute (base class "A" defined the type as "Callable[[str], None]", override has type "Callable[[object], None]")
0 commit comments