Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

special case types.DynamicClassAttribute as property-like #18150

Merged
merged 2 commits into from
Nov 21, 2024
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
1 change: 1 addition & 0 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,7 @@ def visit_decorator(self, dec: Decorator) -> None:
"abc.abstractproperty",
"functools.cached_property",
"enum.property",
"types.DynamicClassAttribute",
),
):
removed.append(i)
Expand Down
18 changes: 18 additions & 0 deletions test-data/unit/pythoneval.test
Original file line number Diff line number Diff line change
Expand Up @@ -2163,3 +2163,21 @@ class C3[T1, T2](tuple[T1, ...]):

def func3(p: C3[int, object]):
x: C3[int, int] = p


[case testDynamicClassAttribute]
# Some things that can break if DynamicClassAttribute isn't handled properly
from types import DynamicClassAttribute
from enum import Enum

class TestClass:
@DynamicClassAttribute
def name(self) -> str: ...

class TestClass2(TestClass, Enum): ...

class Status(Enum):
ABORTED = -1

def imperfect(status: Status) -> str:
return status.name.lower()
Loading