Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,13 @@ def visit_decorator(self, dec: Decorator) -> None:
dec.var.is_classmethod = True
self.check_decorated_function_is_method("classmethod", dec)
elif refers_to_fullname(
d, ("builtins.property", "abc.abstractproperty", "functools.cached_property")
d,
(
"builtins.property",
"abc.abstractproperty",
"functools.cached_property",
"enum.property",
),
):
removed.append(i)
dec.func.is_property = True
Expand Down
23 changes: 23 additions & 0 deletions test-data/unit/pythoneval.test
Original file line number Diff line number Diff line change
Expand Up @@ -1712,3 +1712,26 @@ A = Type[int] | str
B: TypeAlias = Type[int] | str
[out]
m.pyi:5: note: Revealed type is "typing._SpecialForm"

[case testEnumNameWorkCorrectlyOn311]
# flags: --python-version 3.11
import enum

class E(enum.Enum):
X = 1
Y = 2
@enum.property
def foo(self) -> int: ...

e: E
reveal_type(e.name)
reveal_type(e.value)
reveal_type(E.X.name)
reveal_type(e.foo)
reveal_type(E.Y.foo)
[out]
_testEnumNameWorkCorrectlyOn311.py:11: note: Revealed type is "builtins.str"
_testEnumNameWorkCorrectlyOn311.py:12: note: Revealed type is "Union[Literal[1]?, Literal[2]?]"
_testEnumNameWorkCorrectlyOn311.py:13: note: Revealed type is "Literal['X']?"
_testEnumNameWorkCorrectlyOn311.py:14: note: Revealed type is "builtins.int"
_testEnumNameWorkCorrectlyOn311.py:15: note: Revealed type is "builtins.int"