File tree 1 file changed +4
-1
lines changed
1 file changed +4
-1
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 )
You can’t perform that action at this time.
0 commit comments