Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-134215: PyREPL: Do not show underscored modules by default during autocompletion#134267
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from24 commits
Commits
Show all changes
26 commits Select commitHold shift + click to select a range
fd0212d gh-134215: Improve ModuleCompleter module
kevteg3e314e8 Merge branch 'main' into pyrepl_underscored_fix
kevteg7c4f4c8 Remove unused import
kevtegff6b6a3 Merge branch 'pyrepl_underscored_fix' of github.com:kevteg/cpython in…
kevtegf7a2db9 Add news
kevteg2c5f81e Rename method
kevteg1472148 Update method name
kevteg5f97959 Feedback
kevtega04ecdf Feedback
kevtegca89754 Update docstring
kevteg5636adb Merge branch 'main' into pyrepl_underscored_fix
kevtegdc1a403 Merge branch 'pyrepl_underscored_fix' of github.com:kevteg/cpython in…
kevteg4a2872a Update tests
kevtege854d10 Update Lib/test/test_pyrepl/test_pyrepl.py
kevtege3fc8e0 Update Misc/NEWS.d/next/Tools-Demos/2025-05-19-14-57-46.gh-issue-1342…
kevteg4918343 Fix
kevteg04f78cf Merge branch 'pyrepl_underscored_fix' of github.com:kevteg/cpython in…
kevtegff02e15 Merge branch 'main' into pyrepl_underscored_fix
kevteg262b4e1 Merge branch 'main' into pyrepl_underscored_fix
kevteg0323ec3 Small refactor
kevteg038fc4e Merge branch 'pyrepl_underscored_fix' of github.com:kevteg/cpython in…
kevteg76435a0 Merge branch 'main' into pyrepl_underscored_fix
kevteg14cac01 Remove docstring
kevtege1ac435 Merge branch 'pyrepl_underscored_fix' of github.com:kevteg/cpython in…
kevteg1e88864 Update Lib/_pyrepl/_module_completer.py
ambv99a3d6b Merge branch 'main' into pyrepl_underscored_fix
ambvFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -81,8 +81,10 @@ def find_modules(self, path: str, prefix: str) -> list[str]: | ||
| def _find_modules(self, path: str, prefix: str) -> list[str]: | ||
| if not path: | ||
| # Top-level import (e.g. `import foo<tab>`` or `from foo<tab>`)` | ||
| builtin_modules = [name for name in sys.builtin_module_names | ||
| if self.is_suggestion_match(name, prefix)] | ||
| third_party_modules = [module.name for module in self.global_cache | ||
| if self.is_suggestion_match(module.name, prefix)] | ||
| return sorted(builtin_modules + third_party_modules) | ||
| if path.startswith('.'): | ||
| @@ -98,7 +100,14 @@ def _find_modules(self, path: str, prefix: str) -> list[str]: | ||
| if mod_info.ispkg and mod_info.name == segment] | ||
| modules = self.iter_submodules(modules) | ||
| return [module.name for module in modules | ||
| if self.is_suggestion_match(module.name, prefix)] | ||
| def is_suggestion_match(self, module_name: str, prefix: str) -> bool: | ||
| if prefix: | ||
| return module_name.startswith(prefix) | ||
| # Return False if no prefix and the module is private | ||
| # So that the default behavior is only returning public modules | ||
ambv marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| return not module_name.startswith("_") | ||
kevteg marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| def iter_submodules(self, parent_modules: list[pkgutil.ModuleInfo]) -> Iterator[pkgutil.ModuleInfo]: | ||
| """Iterate over all submodules of the given parent modules.""" | ||
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
1 change: 1 addition & 0 deletionsMisc/ACKS
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
1 change: 1 addition & 0 deletionsMisc/NEWS.d/next/Tools-Demos/2025-05-19-14-57-46.gh-issue-134215.sbdDK6.rst
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| :term:`REPL` import autocomplete only suggests private modules when explicitly specified. |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.