-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
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
Add supported \_sunder\_ names to __dir__() method of Enum to support them | ||
in REPL autocompletion. |
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.
This is restructured text.
Add supported \_sunder\_ names to __dir__() method of Enum to support them | |
in REPL autocompletion. | |
Add supported ``_sunder_`` names to the :func:`dir` method of the :mod:`Enum` module | |
to support them in :term:`REPL` autocompletion. |
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.
Thanks for the suggestion! I fixed it
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 <107691772+SimonGPrs@users.noreply.github.com>
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. |
@@ -0,0 +1,2 @@ | |||
Add supported ``_sunder_`` names to the :func:`dir` method of the :mod:`Enum` module |
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.
Add supported ``_sunder_`` names to the :func:`dir` method of the :mod:`Enum` module | |
Add supported ``_sunder_`` names to the :func:`dir` method of the :mod:`enum` module |
Apologies for this omission in my previous suggestion, the directives are case-sensitive.
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.
No worries, fixed!
This change adds the sunder names
_generate_next_value_
and_missing_
to the__dir__
method ofEnumType
andEnum
.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/