Skip to content

Commit 8e294bb

Browse files
committed
support propertied decorators
1 parent eb1b1e0 commit 8e294bb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mypy/semanal.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,7 @@ def visit_decorator(self, dec: Decorator) -> None:
10471047
d.accept(self)
10481048
removed: List[int] = []
10491049
no_type_check = False
1050+
could_be_decorated_property = False
10501051
for i, d in enumerate(dec.decorators):
10511052
# A bunch of decorators are special cased here.
10521053
if refers_to_fullname(d, 'abc.abstractmethod'):
@@ -1094,14 +1095,16 @@ def visit_decorator(self, dec: Decorator) -> None:
10941095
removed.append(i)
10951096
else:
10961097
self.fail("@final cannot be used with non-method functions", d)
1098+
elif not dec.var.is_property:
1099+
could_be_decorated_property = True
10971100
for i in reversed(removed):
10981101
del dec.decorators[i]
10991102
if (not dec.is_overload or dec.var.is_property) and self.type:
11001103
dec.var.info = self.type
11011104
dec.var.is_initialized_in_class = True
11021105
if not no_type_check and self.recurse_into_functions:
11031106
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:
11051108
self.fail('Decorated property not supported', dec)
11061109
if dec.func.is_abstract and dec.func.is_final:
11071110
self.fail(f"Method {dec.func.name} is both abstract and final", dec)

0 commit comments

Comments
 (0)