mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
gh-111181: Fix enum doctests (GH-111180)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
This commit is contained in:
parent
cd6e0a04a1
commit
c4dc5a6ae8
3 changed files with 22 additions and 15 deletions
|
@ -483,6 +483,7 @@ Dataclass support
|
|||
When inheriting from a :class:`~dataclasses.dataclass`,
|
||||
the :meth:`~Enum.__repr__` omits the inherited class' name. For example::
|
||||
|
||||
>>> from dataclasses import dataclass, field
|
||||
>>> @dataclass
|
||||
... class CreatureDataMixin:
|
||||
... size: str
|
||||
|
@ -527,7 +528,8 @@ It is possible to modify how enum members are pickled/unpickled by defining
|
|||
:meth:`__reduce_ex__` in the enumeration class. The default method is by-value,
|
||||
but enums with complicated values may want to use by-name::
|
||||
|
||||
>>> class MyEnum(Enum):
|
||||
>>> import enum
|
||||
>>> class MyEnum(enum.Enum):
|
||||
... __reduce_ex__ = enum.pickle_by_enum_name
|
||||
|
||||
.. note::
|
||||
|
@ -770,7 +772,7 @@ be combined with them (but may lose :class:`IntFlag` membership::
|
|||
>>> Perm.X | 4
|
||||
<Perm.R|X: 5>
|
||||
|
||||
>>> Perm.X | 8
|
||||
>>> Perm.X + 8
|
||||
9
|
||||
|
||||
.. note::
|
||||
|
@ -1435,8 +1437,9 @@ alias::
|
|||
... GRENE = 2
|
||||
...
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
...
|
||||
ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'
|
||||
Error calling __set_name__ on '_proto_member' instance 'GRENE' in 'Color'
|
||||
|
||||
.. note::
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue