Skip to content

gh-139819: rlcompleter – avoid suggesting attributes not accessible on instances - #139820

Merged
ethanfurman merged 9 commits into
python:mainfrom
ttw225:fix/rlcompleter
Jun 9, 2026
Merged

gh-139819: rlcompleter – avoid suggesting attributes not accessible on instances#139820
ethanfurman merged 9 commits into
python:mainfrom
ttw225:fix/rlcompleter

Conversation

@ttw225

@ttw225ttw225 commented Oct 9, 2025

Copy link
Copy Markdown
Contributor

Fix tab-completion suggesting names that are not accessible on instances
(e.g., Enum members showing __name__).

Change

In rlcompleter.attr_matches(), when getattr(thisobject, word, None)
is None, only add the candidate if hasattr(thisobject, word) is true.

Effect

Removes bogus suggestions without affecting valid completions.

Bogus suggestions

['Color.BLUE.__iter__',
'Color.BLUE.__getitem__',
'Color.BLUE.__members__',
'Color.BLUE.__contains__',
'Color.BLUE.__qualname__',
'Color.BLUE.__len__',
'Color.BLUE.__name__']
# Additionally seen among bogus suggestions:
'Enum.__abstractmethods__'

@ttw225

Copy link
Copy Markdown
ContributorAuthor

Noted the CI Test failure. I’m working on a fix and will push soon.

@ttw225

Copy link
Copy Markdown
ContributorAuthor

Tests have passed. Thanks for reviewing!

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actionsgithub-actionsBot added the stale Stale PR or inactive for long period of time. label Apr 30, 2026
@ethanfurman
ethanfurman merged commit 81c1cdc into python:mainJun 9, 2026
52 checks passed
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Jun 9, 2026
…ible on instances (pythonGH-139820)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Comment threadLib/rlcompleter.py
__all__ = ["Completer"]

# Sentinel object to distinguish "missing" from "present but None"
_SENTINEL = object()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use the new sentinel builtin?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #151222.

@ttw225
ttw225 deleted the fix/rlcompleter branch June 11, 2026 02:41
philthompson10 pushed a commit to philthompson10/cpython that referenced this pull request Jun 17, 2026
…ible on instances (pythonGH-139820)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

staleStale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@ttw225@danielhollas@Viicos@ethanfurman@nazeerali4325-commits