From 1b0428dee57bd5aea306bd81a576a3fa55ff6201 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 22 Feb 2022 19:27:49 +0300 Subject: [PATCH 1/2] Update `Enum` docs After merging https://github.com/python/mypy/pull/11805 I found out that we are missing several new `Enum` features. This PR adds them to the docs. Refs https://github.com/python/mypy/pull/12026 Refs https://github.com/python/mypy/pull/12035 --- docs/source/literal_types.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/source/literal_types.rst b/docs/source/literal_types.rst index d5271b256bb2..97d10e81daad 100644 --- a/docs/source/literal_types.rst +++ b/docs/source/literal_types.rst @@ -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 @@ -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" + ... From abaaca21b6e97ea37e22547d1bf7fda00ceac940 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 22 Feb 2022 20:01:43 +0300 Subject: [PATCH 2/2] Update docs/source/literal_types.rst --- docs/source/literal_types.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/literal_types.rst b/docs/source/literal_types.rst index 97d10e81daad..c5df354ce678 100644 --- a/docs/source/literal_types.rst +++ b/docs/source/literal_types.rst @@ -489,7 +489,7 @@ Extra checks: 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. +- Base classes have no conflicts and mixin types are correct. .. code-block:: python