diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-10-30 19:56:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 19:56:29 (GMT) |
commit | c4dc5a6ae8aa13abb743182df088f1a3526d1bcd (patch) | |
tree | 8f4ac272a831679e9d3417ee2223d13be25568df /Doc/howto/enum.rst | |
parent | cd6e0a04a16535d8bc727c84f73730c53267184e (diff) | |
download | cpython-c4dc5a6ae8aa13abb743182df088f1a3526d1bcd.zip cpython-c4dc5a6ae8aa13abb743182df088f1a3526d1bcd.tar.gz cpython-c4dc5a6ae8aa13abb743182df088f1a3526d1bcd.tar.bz2 |
gh-111181: Fix enum doctests (GH-111180)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Diffstat (limited to 'Doc/howto/enum.rst')
-rw-r--r-- | Doc/howto/enum.rst | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/howto/enum.rst b/Doc/howto/enum.rst index ebaa1cf..0830fb6 100644 --- a/Doc/howto/enum.rst +++ b/Doc/howto/enum.rst @@ -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:: |