-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
gh-139398: Add supported sunder names to Enum __dir__ for REPL completions
#139985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| Attribute(name='_missing_', kind='class method', | ||
| defining_class=Enum, object=self.Color._missing_), | ||
| Attribute(name='_generate_next_value_', kind='static method', | ||
| defining_class=self.Color, object=staticmethod(self.Color._generate_next_value_)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to adjust this test to expect the new attributes, but I wasn't able to get the test to pass. I guess I need some help here 🙂 thanks!
./python -m unittest -v test.test_enum.TestStdLib.test_inspect_classify_class_attrs
Misc/NEWS.d/next/Library/2025-10-12-08-46-26.gh-issue-139398.hESOMl.rst
Outdated
Show resolved
Hide resolved
This change adds the sunder names `_generate_next_value_` and `_missing_` to the `__dir__` method of `EnumType` and `Enum`. In Addition, The instance level sunder names `_add_alias_` and `_add_value_alias_` are added to `Enum.__dir__`. With the sunder names exposed in the `dir()` method, the REPL autocomplete will also show them. Co-Authored-By: SimonGPrs <[email protected]>
This change highlights which of the attributes were expected versus were actually there.
bafd9e3 to
0d9fedf
Compare
|
Please don't force push, it complicates reviewing. All commits are squashed at the end anyway. |
This change adds the sunder names
_generate_next_value_and_missing_to the__dir__method ofEnumTypeandEnum.In Addition, The instance level sunder names
_add_alias_and_add_value_alias_are added toEnum.__dir__.With the sunder names exposed in the
dir()method, the REPL autocomplete will also show them.Note: This PR is based on the first attempt to address this issue: #139418
Preview:
📚 Documentation preview 📚: https://cpython-previews--139985.org.readthedocs.build/