File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -2285,11 +2285,19 @@ def check_method_override_for_base_with_name(
22852285 isinstance (original_node , Var )
22862286 and original_node .is_classvar
22872287 and defn .name == original_node .name
2288- and isinstance (defn , Decorator )
2288+ and ( isinstance (defn , ( Decorator , OverloadedFuncDef )) )
22892289 ):
2290- self .fail (
2291- message_registry .CANNOT_OVERRIDE_CLASS_VAR .format (base .name ), defn .func
2292- )
2290+ decorator_func = None
2291+ if isinstance (defn , Decorator ):
2292+ decorator_func = defn .func
2293+ elif isinstance (defn .items [0 ], Decorator ):
2294+ decorator_func = defn .items [0 ].func
2295+
2296+ if decorator_func :
2297+ self .fail (
2298+ message_registry .CANNOT_OVERRIDE_CLASS_VAR .format (base .name ),
2299+ decorator_func ,
2300+ )
22932301
22942302 if (
22952303 isinstance (original_node , Var )
Original file line number Diff line number Diff line change @@ -277,10 +277,12 @@ class A:
277277class B(A):
278278 @property
279279 def x(self) -> int: ...
280+
281+ @x.setter
282+ def x(self, value: int) -> None: ...
280283[builtins fixtures/property.pyi]
281284[out]
282285main:7: error: Cannot override class variable (previously declared on base class "A") with instance variable
283- main:7: error: Cannot override writeable attribute with read-only property
284286
285287[case testAcrossModules]
286288import m
You can’t perform that action at this time.
0 commit comments