Skip to content

Commit

Permalink
Update Enum docs
Browse files Browse the repository at this point in the history
After merging #11805 I found out that we are missing several new `Enum` features.

This PR adds them to the docs.

Refs #12026
Refs #12035
  • Loading branch information
sobolevn authored Feb 22, 2022
1 parent 784b67e commit 1b0428d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs/source/literal_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ Enums
-----

Mypy has special support for :py:class:`enum.Enum` and its subclasses:
:py:class:`enum.IntEnum`, :py:class:`enum.Flag`, and :py:class:`enum.IntFlag`.
:py:class:`enum.IntEnum`, :py:class:`enum.Flag`, :py:class:`enum.IntFlag`,
and :py:class:`enum.StrEnum`.

.. code-block:: python
Expand Down Expand Up @@ -487,3 +488,14 @@ Extra checks:
class Some(Enum):
x = 1
x = 2 # E: Attempted to reuse member name "x" in Enum definition "Some"
- Base classes have no conflicts and mixing types are correct.

.. code-block:: python
class WrongEnum(str, int, enum.Enum):
# E: Only a single data type mixin is allowed for Enum subtypes, found extra "int"
...
class MixinAfterEnum(enum.Enum, Mixin): # E: No base classes are allowed after "enum.Enum"
...

0 comments on commit 1b0428d

Please sign in to comment.