Files
2025-12-04 14:02:23 +00:00

39 lines
685 B
HTML

<html>
<body>
<p>
Reports invalid definition and usage of <a href="https://peps.python.org/pep-0435/">Enum</a>.
</p>
<p>
<b>Example:</b>
</p>
<pre><code>
from enum import Enum
class Shape(Enum):
SQUARE = 1
CIRCLE = 2
class ExtendedShape(Shape): # Enum class 'Shape' is final and cannot be subclassed
TRIANGLE = 3
</code></pre>
<pre><code>
from enum import Enum
class Color(Enum):
_value_: int
RED = 1
GREEN = "green" # Type 'str' is not assignable to declared type 'int'
</code></pre>
<pre><code>
from enum import Enum
class Pet(Enum):
CAT = 1
DOG: int = 2 # Type annotations are not allowed for enum members
</code></pre>
</body>
</html>