From 4f287221407984f1f11b8a374e8861de0ba901e6 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Thu, 18 Jan 2024 08:53:56 -0800 Subject: [PATCH] Fixed a few more formatting issues. --- docs/spec/enums.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/spec/enums.rst b/docs/spec/enums.rst index 9b10af23c..23a4e908b 100644 --- a/docs/spec/enums.rst +++ b/docs/spec/enums.rst @@ -35,7 +35,7 @@ If a type checker supports the functional syntax, it should enforce name consistency. That is, if the type is assigned to a variable, the name of the variable must match the name of the enum class:: - WrongName = Enum('Color', 'RED GREEN BLUE') # Type checker error + WrongName = Enum('Color', 'RED GREEN BLUE') # Type checker error Enum classes can also be defined using a subclass of ``enum.Enum`` or any class that uses ``enum.EnumType`` (or a subclass thereof) as a metaclass. Type @@ -74,10 +74,10 @@ behaviors:: BLUE = 3 for color in Color: - reveal_type(color) # Revealed type is 'Color' + reveal_type(color) # Revealed type is 'Color' - reveal_type(Color["RED"]) # Revealed type is 'Literal[Color.RED]' (or 'Color') - reveal_type(Color(3)) # Revealed type is 'Literal[Color.BLUE]' (or 'Color') + reveal_type(Color["RED"]) # Revealed type is 'Literal[Color.RED]' (or 'Color') + reveal_type(Color(3)) # Revealed type is 'Literal[Color.BLUE]' (or 'Color') Calling an enum class does not invoke its constructor, as is normal in most Python classes. The defined ``__new__`` method of an enum class is @@ -277,7 +277,7 @@ may support these to infer literal types for member values:: GREEN = auto() BLUE = auto() - reveal_type(Color.RED.value) # Revealed type is Literal[1] (or int or object or Any) + reveal_type(Color.RED.value) # Revealed type is Literal[1] (or int or object or Any) If an enum class provides an explicit type annotation for ``_value_``, type