diff --git a/mypy/semanal.py b/mypy/semanal.py index 59e4594353f0..9d2d6f5fa484 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -1684,6 +1684,7 @@ def visit_decorator(self, dec: Decorator) -> None: "abc.abstractproperty", "functools.cached_property", "enum.property", + "types.DynamicClassAttribute", ), ): removed.append(i) diff --git a/test-data/unit/pythoneval.test b/test-data/unit/pythoneval.test index 4942a5fd5f2f..70003545754c 100644 --- a/test-data/unit/pythoneval.test +++ b/test-data/unit/pythoneval.test @@ -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()