Skip to content

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

Open
ttw225 wants to merge 9 commits into
python:mainfrom
ttw225:fix/rlcompleter
Open

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

Conversation

@ttw225

@ttw225 ttw225 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

ttw225 commented Oct 9, 2025

Copy link
Copy Markdown
Contributor Author

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

@ttw225

ttw225 commented Oct 9, 2025

Copy link
Copy Markdown
Contributor Author

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-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants