-
-
Notifications
You must be signed in to change notification settings - Fork 33k
gh-139398: Make dir(Enum) include public _sunder_ helpers for REPL completions #139418
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
…for REPL completions (pythongh-139398) - I guess this enhances EnumType.__dir__ to include documented public _sunder_ helpers (_add_alias_, _add_value_alias_) if present on the Enum class - I think this could enabrle rlcompleter and the REPL show completions for these supported helpers and matching the intent of the enum API docs... - Normally I think no change to other (private or internal) _sunder_ names - Fixes: pythongh-139398
This comment was marked as resolved.
This comment was marked as resolved.
…tions (pythongh-139398) Fix indentation in EnumType.__dir__ (pythongh-139398) Add NEWS entry for enum dir(Enum) completions (pythongh-139398)
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
- Remove trailing spaces to satisfy lint/pre-commit checks - The code itself is not chnaged it is just the issue of the test
This comment was marked as resolved.
This comment was marked as resolved.
interesting = set([ | ||
'__class__', '__contains__', '__doc__', '__getitem__', | ||
'__iter__', '__len__', '__members__', '__module__', | ||
'__name__', '__qualname__', | ||
] + cls._member_names_) | ||
|
||
if cls._new_member_ is not object.__new__: | ||
interesting.add('__new__') | ||
if cls.__init_subclass__ is not object.__init_subclass__: | ||
interesting.add('__init_subclass__') | ||
|
||
# SGP: Include documented public _sunder_ helpers defined on the Enum class. | ||
# SGP: This makes them discoverable via dir(Enum) so rlcompleter can surface | ||
# SGP: them in REPL completions. (rlcompleter drives dotted-name completion | ||
# SGP: from dir(); _add_alias_/_add_value_alias_ are supported _sunder_ APIs.) | ||
for _n in ("_add_alias_", "_add_value_alias_"): | ||
if _n in cls.__dict__: | ||
interesting.add(_n) | ||
|
||
if cls._member_type_ is object: | ||
return sorted(interesting) | ||
else: | ||
# return whatever mixed-in data type has | ||
# SGP: union the mixin's dir() with 'interesting' | ||
return sorted(set(dir(cls._member_type_)) | interesting) |
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.
The indentation is missed up.
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 corrected the indentation I thought! OK I guess I am really not good enough...I should not have tried contributing and will first try to improve myself, I am sorry.
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.
Everyone makes such small mistakes, all contributions are welcome:-) I think you accidentally unindented the whole section in 01d3a59
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I am not a bot... |
Thank you! I am not great but studying intensly. |
OK I am sorry for the time taken to all of you and this catastrophic pull request, I will take some months on my side and try to improve. |
OK I will have a look, I guess I am just bad, or at least not good enough to try to do that. |
Thanks for making the requested changes! @ethanfurman: please review the changes made to this pull request. |
Wait why are asking to review? I did not make any changes yet! |
It seems like a bug in the bot, not your fault. |
OK I had not understood that he was a bot...I realized I am not good enough anyway. I will give this one last try and then give up. Hopefully I am not blacklisted. I guess I am stupid. I thought I could be strong enough to fix this. Anyway...I guess it was extreme hubris. |
@SimonGPrs: Don't give up! Most PRs need some extra work. As long as you're learning, keep on trying. :-) |
Thank you for your incredible patience, I thought I would generate an huge amount of frustration on your side! Thanks you! I will do my best to improve. |
That's because you quoted the message that contained the sentence that asked for a review :) |
@SimonGPrs I feel ashamed of my accusation and regret it... You are very welcome here and I am sure you can do it 😊 |
Many thanks! I will try to find simpler open source project, I think I have been a bit crazy ambitious... but thank you for the warmth of this community! |
…for REPL completions (gh-139398)