Files
Petrandintellij-monorepo-bot 16d40e9c5d PY-76830 PY-76833 PY-76843 PY-76879 Enums support
GitOrigin-RevId: 9021c003cde70c39f8a5635b42761c08049490e2
2024-11-13 18:30:03 +00:00

39 lines
693 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>