Skip to content

enum docs display incorrect output for dir #107957

Description

@ujan-r

The __dir__ methods for EnumType/EnumMeta and Enum were changed in Python 3.11, but the documentation hasn't been updated. For example:

cpython/Doc/howto/enum.rst

Lines 1053 to 1056 in a2a4b9f

>>> dir(Planet) # doctest: +SKIP
['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', 'VENUS', '__class__', '__doc__', '__members__', '__module__']
>>> dir(Planet.EARTH) # doctest: +SKIP
['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', 'surface_gravity', 'value']

The actual output (for Python 3.11+) is:

>>> dir(Planet)
['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', 'VENUS', '__class__', '__contains__', '__doc__', '__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', '__module__', '__name__', '__qualname__']
>>> dir(Planet.EARTH)
['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', 'VENUS', '__class__', '__doc__', '__eq__', '__hash__', '__module__', 'mass', 'name', 'radius', 'surface_gravity', 'value']

There are other examples with incorrect outputs in Doc/library/enum.rst.

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dir

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions