Conversation
…embers Adds a mechanism that filters a module's public members for showing on autocomplete.
Contributor
Author
|
CC @ambv @pablogsal |
loic-simon
reviewed
Aug 27, 2026
loic-simon
left a comment
Contributor
There was a problem hiding this comment.
Two notes:
- The suggested imports are filtered by
self.is_suggestion_matchlater, which means that if a module explicitely exposed a "private" name (starting with an_) in its__all__, it will be excluded unless the user search for private arguments. That may be a case edgy enough to ignore? - If the user search for a name that can be imported but is not in
__all__, do we really want the REPL to hide it? I quite like the current behavior with_-private names (hide them unless explicitely asked for), so maybe we could restrict to__all__only for barefron json importcompletions, and usedirotherwise? This is a more opinionatred question, tied to the debates around PEP 842-44 😅
Contributor
Author
|
Hello @loic-simon thank you for your feedback and for pointing out those overlooks. I would definitely keep an eye out on PEP 842-44 and discussions for many of those decisions.
Added comment on discussion https://discuss.python.org/t/python-api-exposure-mechanisms-public-internal-determining-status-quo/108869/35 |
edvilme
commented
Sep 24, 2026
| if hasattr(imported_module, '__all__'): # Return __all__ directly | ||
| names = [ | ||
| attr_name for attr_name in imported_module.__all__ | ||
| if attr_name.startswith(prefix) and attr_name.isidentifier() |
Contributor
Author
There was a problem hiding this comment.
Added as per discussion in https://discuss.python.org/t/python-api-exposure-mechanisms-public-internal-determining-status-quo/108869/36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates PyREPL autocomplete on import statements to only expose public members if declared with
__all__Before
After