mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-27 04:22:42 +07:00
39 lines
693 B
HTML
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> |