File tree 2 files changed +6
-3
lines changed
2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -1047,6 +1047,7 @@ def visit_decorator(self, dec: Decorator) -> None:
1047
1047
d .accept (self )
1048
1048
removed : List [int ] = []
1049
1049
no_type_check = False
1050
+ could_be_decorated_property = False
1050
1051
for i , d in enumerate (dec .decorators ):
1051
1052
# A bunch of decorators are special cased here.
1052
1053
if refers_to_fullname (d , 'abc.abstractmethod' ):
@@ -1094,14 +1095,16 @@ def visit_decorator(self, dec: Decorator) -> None:
1094
1095
removed .append (i )
1095
1096
else :
1096
1097
self .fail ("@final cannot be used with non-method functions" , d )
1098
+ elif not dec .var .is_property :
1099
+ could_be_decorated_property = True
1097
1100
for i in reversed (removed ):
1098
1101
del dec .decorators [i ]
1099
1102
if (not dec .is_overload or dec .var .is_property ) and self .type :
1100
1103
dec .var .info = self .type
1101
1104
dec .var .is_initialized_in_class = True
1102
1105
if not no_type_check and self .recurse_into_functions :
1103
1106
dec .func .accept (self )
1104
- if dec .decorators and dec .var .is_property :
1107
+ if could_be_decorated_property and dec .decorators and dec .var .is_property :
1105
1108
self .fail ('Decorated property not supported' , dec )
1106
1109
if dec .func .is_abstract and dec .func .is_final :
1107
1110
self .fail (f"Method { dec .func .name } is both abstract and final" , dec )
Original file line number Diff line number Diff line change @@ -1231,7 +1231,7 @@ from typing import overload
1231
1231
class A:
1232
1232
@overload # E: An overloaded function outside a stub file must have an implementation
1233
1233
def f(self) -> int: pass
1234
- @property # E: Decorated property not supported
1234
+ @property
1235
1235
@overload
1236
1236
def f(self) -> int: pass
1237
1237
[builtins fixtures/property.pyi]
@@ -1244,7 +1244,7 @@ class A:
1244
1244
@dec # E: Decorated property not supported
1245
1245
@property
1246
1246
def f(self) -> int: pass
1247
- @property # E: Decorated property not supported
1247
+ @property
1248
1248
@dec
1249
1249
def g(self) -> int: pass
1250
1250
[builtins fixtures/property.pyi]
You can’t perform that action at this time.
0 commit comments