Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-69605: Hardcode some stdlib submodules in PyREPL module completion (os.path, collections.abc...)#138268
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
python-cla-botbot commentedAug 30, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Core_and_Builtins/2025-08-30-17-15-05.gh-issue-69605.KjBk99.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Thanks! I was planning to implement this at some point, but you beat me to it :) I haven't checked too deeply, but we should make sure to only autocomplete these submodules when we are sure they are coming from the stdlib. We do not want to autocomplete them when a user intentionally shadows an stdlib module with their own because in that case they might not exist. |
Yeah, I wondered about that, I'll check if we have a reliable and fast way to check this. Just looking at A side note on this: when testing the current behavior by creating a folder % mkdir collections% touch collections/__init__.py collections/foo.py% pythonPython 3.14.0rc2 [...]>>>from collectionsimport<TAB>>>>from collectionsimport fooTraceback (most recent call last): File "<python-input-0>", line 1, in <module> from collections import fooImportError: cannot import name 'foo' from 'collections' (/Users/loic/cpython/Lib/collections/__init__.py)>>>% python -c "from collections import foo; print(foo)"<module 'collections.foo' from '/Users/loic/test/collections/foo.py'> Not directly related, but it may be cool to check if the name to complete is already in |
537133d intopython:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@loic-simon for the PR, and@ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…letion (os.path, collections.abc...) (pythonGH-138268)(cherry picked from commit537133d)Co-authored-by: Loïc Simon <loic.simon@napta.io>Co-authored-by: Łukasz Langa <lukasz@langa.pl>
GH-138943 is a backport of this pull request to the3.14 branch. |
Adressed in#139461. |
Uh oh!
There was an error while loading.Please reload this page.
From#69605 (comment):
This PR adds a hardcoded dictionary of unusual standard library submodules that
pkgutil.iter_modulescan't find despite them being importable, so we can suggest them anyway.The hardcoded dictionary comes from checking alldocumented modules to find which submodules
_pyrepl._module_completer.ModuleCompleterwas unable to detect.I wrote a test to ensure all hardcoded modules are indeed importable, but I'm not sure we can programatically detect eventual new modules so we don't forget to add them, but it should be rare enough to not be too much a concern.
cc@tomasr8