@@ -201,7 +201,7 @@ Data Types
201
201
202
202
.. method :: EnumType.__getitem__(cls, name)
203
203
204
- Returns the Enum member in *cls * matching *name *, or raises an :exc: `KeyError `::
204
+ Returns the Enum member in *cls * matching *name *, or raises a :exc: `KeyError `::
205
205
206
206
>>> Color['BLUE']
207
207
<Color.BLUE: 3>
@@ -248,7 +248,7 @@ Data Types
248
248
249
249
.. note :: Enum member values
250
250
251
- Member values can be anything: :class: `int `, :class: `str `, etc.. If
251
+ Member values can be anything: :class: `int `, :class: `str `, etc. If
252
252
the exact value is unimportant you may use :class: `auto ` instances and an
253
253
appropriate value will be chosen for you. See :class: `auto ` for the
254
254
details.
@@ -262,7 +262,7 @@ Data Types
262
262
names will also be removed from the completed enumeration. See
263
263
:ref: `TimePeriod <enum-time-period >` for an example.
264
264
265
- .. method :: Enum.__call__(cls, value, names=None, \ *, module=None, qualname=None, type=None, start=1, boundary=None)
265
+ .. method :: Enum.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
266
266
267
267
This method is called in two different ways:
268
268
@@ -279,8 +279,8 @@ Data Types
279
279
:module: The name of the module the new Enum is created in.
280
280
:qualname: The actual location in the module where this Enum can be found.
281
281
:type: A mix-in type for the new Enum.
282
- :start: The first integer value for the Enum (used by :class: `auto `)
283
- :boundary: How to handle out-of-range values from bit operations (:class: `Flag ` only)
282
+ :start: The first integer value for the Enum (used by :class: `auto `).
283
+ :boundary: How to handle out-of-range values from bit operations (:class: `Flag ` only).
284
284
285
285
.. method :: Enum.__dir__(self)
286
286
@@ -322,7 +322,7 @@ Data Types
322
322
>>> PowersOfThree.SECOND.value
323
323
6
324
324
325
- .. method :: Enum.__init_subclass__(cls, \ **kwds)
325
+ .. method :: Enum.__init_subclass__(cls, **kwds)
326
326
327
327
A *classmethod * that is used to further configure subsequent subclasses.
328
328
By default, does nothing.
@@ -380,7 +380,7 @@ Data Types
380
380
.. method :: Enum.__format__(self)
381
381
382
382
Returns the string used for *format() * and *f-string * calls. By default,
383
- returns :meth: `__str__ ` returns , but can be overridden::
383
+ returns :meth: `__str__ ` return value , but can be overridden::
384
384
385
385
>>> class OtherStyle(Enum):
386
386
... ALTERNATE = auto()
@@ -559,11 +559,11 @@ Data Types
559
559
Using :class: `auto ` with :class: `Flag ` results in integers that are powers
560
560
of two, starting with ``1 ``.
561
561
562
- .. versionchanged :: 3.11 The *repr()* of zero-valued flags has changed. It
562
+ .. versionchanged :: 3.11 The *repr()* of zero-valued flags has changed. It
563
563
is now::
564
564
565
- >>> Color(0) # doctest: +SKIP
566
- <Color: 0>
565
+ >>> Color(0) # doctest: +SKIP
566
+ <Color: 0>
567
567
568
568
.. class :: IntFlag
569
569
@@ -607,7 +607,7 @@ Data Types
607
607
*replacement of existing constants * use-case. :meth: `~object.__format__ ` was
608
608
already :meth: `!int.__format__ ` for that same reason.
609
609
610
- Inversion of a :class: `!IntFlag ` now returns a positive value that is the
610
+ Inversion of an :class: `!IntFlag ` now returns a positive value that is the
611
611
union of all flags not in the given flag, rather than a negative value.
612
612
This matches the existing :class: `Flag ` behavior.
613
613
@@ -619,7 +619,7 @@ Data Types
619
619
* :meth: `!int.__str__ ` for :class: `IntEnum ` and :class: `IntFlag `
620
620
* :meth: `!str.__str__ ` for :class: `StrEnum `
621
621
622
- Inherit from :class: `!ReprEnum ` to keep the :class: `str() <str> / :func:`format `
622
+ Inherit from :class: `!ReprEnum ` to keep the :class: `str() <str> ` / :func: `format `
623
623
of the mixed-in data type instead of using the
624
624
:class: `Enum `-default :meth: `str() <Enum.__str__> `.
625
625
@@ -665,7 +665,7 @@ Data Types
665
665
.. attribute :: NAMED_FLAGS
666
666
667
667
Ensure that any flag groups/masks contain only named flags -- useful when
668
- values are specified instead of being generated by :func: `auto `
668
+ values are specified instead of being generated by :func: `auto `::
669
669
670
670
>>> from enum import Flag, verify, NAMED_FLAGS
671
671
>>> @verify(NAMED_FLAGS)
@@ -897,23 +897,23 @@ Notes
897
897
898
898
:class: `IntEnum `, :class: `StrEnum `, and :class: `IntFlag `
899
899
900
- These three enum types are designed to be drop-in replacements for existing
901
- integer- and string-based values; as such, they have extra limitations:
900
+ These three enum types are designed to be drop-in replacements for existing
901
+ integer- and string-based values; as such, they have extra limitations:
902
902
903
- - ``__str__ `` uses the value and not the name of the enum member
903
+ - ``__str__ `` uses the value and not the name of the enum member
904
904
905
- - ``__format__ ``, because it uses ``__str__ ``, will also use the value of
906
- the enum member instead of its name
905
+ - ``__format__ ``, because it uses ``__str__ ``, will also use the value of
906
+ the enum member instead of its name
907
907
908
- If you do not need/want those limitations, you can either create your own
909
- base class by mixing in the ``int `` or ``str `` type yourself::
908
+ If you do not need/want those limitations, you can either create your own
909
+ base class by mixing in the ``int `` or ``str `` type yourself::
910
910
911
- >>> from enum import Enum
912
- >>> class MyIntEnum(int, Enum):
913
- ... pass
911
+ >>> from enum import Enum
912
+ >>> class MyIntEnum(int, Enum):
913
+ ... pass
914
914
915
915
or you can reassign the appropriate :meth: `str `, etc., in your enum::
916
916
917
- >>> from enum import IntEnum
918
- >>> class MyIntEnum(IntEnum):
919
- ... __str__ = IntEnum.__str__
917
+ >>> from enum import IntEnum
918
+ >>> class MyIntEnum(IntEnum):
919
+ ... __str__ = IntEnum.__str__
0 commit comments