Documentation
Several examples in Doc/library/enum.rst are meant to be runnable as standalone doctest-style blocks, but a few miss required imports (Enum, auto, StrEnum). Adding minimal from enum import ... lines makes each block self-contained.
The current documentation is correct; this change simply improves convenience for newcomers and first-time readers by making the snippets runnable in isolation.
Example (why this helps):
Before (fails):
>>> class Weekday(Enum):
... MONDAY = 1
NameError: name 'Enum' is not defined
After (works):
>>> from enum import Enum
>>> class Weekday(Enum):
... MONDAY = 1
Notes
- The change aims to be minimal and localized to the affected blocks.
- No NEWS entry should be required (docs-only).
Linked PRs
Documentation
Several examples in
Doc/library/enum.rstare meant to be runnable as standalone doctest-style blocks, but a few miss required imports (Enum,auto,StrEnum). Adding minimalfrom enum import ...lines makes each block self-contained.The current documentation is correct; this change simply improves convenience for newcomers and first-time readers by making the snippets runnable in isolation.
Example (why this helps):
Before (fails):
After (works):
Notes
Linked PRs
Enumexamples (GH-139488) #139493Enumexamples (GH-139488) #139494