Repository navigation
Readline completion of module names in import statements #69605
Copy link
Copy link
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-featureA feature request or enhancementA feature request or enhancement
Description
| BPO | 25419 |
|---|---|
| Nosy | @vadmium, @serhiy-storchaka, @MojoVampire |
| Dependencies | |
| Files |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = None
created_at = <Date 2015-10-16.11:16:48.120>
labels = ['type-feature', 'library']
title = 'Readline completion of module names in import statements'
updated_at = <Date 2016-05-25.08:03:01.876>
user = 'https://github.com/vadmium'bugs.python.org fields:
activity = <Date 2016-05-25.08:03:01.876>
actor = 'martin.panter'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2015-10-16.11:16:48.120>
creator = 'martin.panter'
dependencies = ['16182']
files = ['40794', '42986']
hgrepos = []
issue_num = 25419
keywords = ['patch']
message_count = 6.0
messages = ['253072', '253095', '253104', '253115', '253132', '266320']
nosy_count = 3.0
nosy_names = ['martin.panter', 'serhiy.storchaka', 'josh.r']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue25419'
versions = ['Python 3.6']Linked PRs
- gh-69605: Add module autocomplete to PyREPL #129329
- gh-69605: Add PyREPL import autocomplete feature to 'What's New' #133358
- gh-69605: Disable PyREPL module autocomplete fallback on regular completion #134181
- [3.14] gh-69605: Disable PyREPL module autocomplete fallback on regular completion (gh-134181) #134680
- gh-69605: Hardcode some stdlib submodules in PyREPL module completion (os.path, collections.abc...) #138268
- [3.14] gh-69605: Hardcode some stdlib submodules in PyREPL module completion (os.path, collections.abc...) (GH-138268) #138943
- gh-69605: Check for already imported modules in PyREPL module completion #139461
- gh-69605: In test_pyrepl.test_already_imported*, invalidate FS import caches #143436
- [3.14] gh-69605: Check for already imported modules in PyREPL module completion #143438
- gh-69605: Add math.integer to PyREPL module completer hardcoded list #144811
- gh-69605: PyREPL: insert "import" after "from foo <tab>" #148445
- gh-69605: fix PyREPL completions inserted for import statements with spaces #148629
- [3.15] gh-69605: fix PyREPL completions inserted for import statements with spaces (GH-148629) #159989
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-featureA feature request or enhancementA feature request or enhancement
Activity
Merge remote-tracking branch 'origin/main' into call-len
loic-simon commentedon May 17, 2025
Shouldn't we totally disable completion on import attributes?
Since completions don't come from module attributes but current namespace, I find it pretty misleading, and unlikely to be useful.
Eg. on 3.14 / current main,
while the user probably wanted to import
NamedTuple: since we deferred completion of attributes, I believe it would be best to provide no suggestion at all.tomasr8 commentedon May 17, 2025
That sounds reasonable to me! Would you like to send a PR for that? We'd most likely need to modify
ModuleCompleter.get_completionsto somehow distinguish between:ImportParser.parsereturnsNone) andCurrently we just return an empty list for both.
loic-simon commentedon May 18, 2025
Sure, I'll have a go at it, thanks for the pointers!
tomasr8 commentedon May 18, 2025
Feel free to ping me if you need help!
loic-simon commentedon May 18, 2025
Done, it was pretty straightforward indeed! 🚀
Two other things I noted while working on it:
from collections.doesn't suggestcollections.abc(whereashttp.serverworks). Do you know why / if this is can be fixed? Looks likepkgutils.iter_modulesreturns nothing, but I didn't investigate further.from typing <TAB>completed theimportkeyword?ImportParser.parse()returns None in such a case, and I don't know if there is precedent for completing after a space, might be a litte bit too magical?tomasr8 commentedon May 18, 2025
Thanks! I'll review it tomorrow.
This is expected,
collections.abcis not a real module, same foros.pathso pkgutil won't find it. One thing we could do is hardcode these modules but I haven't had the time to look into it.Yup! I'm already working on that along with general improvements to the parser :)
gh-69605: Disable PyREPL module autocomplete fallback on regular comp…
pythongh-69605: Disable PyREPL module autocomplete fallback on regula…
[3.14] gh-69605: Disable PyREPL module autocomplete fallback on regul…
pythongh-69605: Add PyREPL import autocomplete feature to 'What's New' (
pythongh-69605: Disable PyREPL module autocomplete fallback on regula…
pythongh-69605: Disable PyREPL module autocomplete fallback on regula…
picnixz commentedon Aug 30, 2025
Closing since this was actually completed.
loic-simon commentedon Aug 30, 2025
That reminded me of this issue:
I went ahead and opened a small PR to do just that, let me know if it should become a separate issue!
picnixz commentedon Aug 30, 2025
Let's just reopen it.
gh-69605: Hardcode some stdlib submodules in PyREPL module completion…
pythongh-69605: Hardcode some stdlib submodules in PyREPL module comp…
[3.14] gh-69605: Hardcode some stdlib submodules in PyREPL module com…
gh-69605: Check for already imported modules in PyREPL module complet…
pythongh-69605: In test_pyrepl.test_already_imported*, invalidate FS …
gh-69605: In test_pyrepl.test_already_imported*, invalidate FS import…
pythongh-69605: Check for already imported modules in PyREPL module c…
pythongh-69605: In test_pyrepl.test_already_imported*, invalidate FS …
[3.14] gh-69605: Check for already imported modules in PyREPL module …
loic-simon commentedon Jan 5, 2026
Nice, I think this issue can be closed again!
pythongh-69605: Check for already imported modules in PyREPL module c…
pythongh-69605: In test_pyrepl.test_already_imported*, invalidate FS …
gh-69605: Add math.integer to PyREPL module completer hardcoded list (#…
loic-simon commentedon Apr 10, 2026
Hey @tomasr8, is this still on your radar? I'd love to see this land someday, can have a try at it if needed!
tomasr8 commentedon Apr 11, 2026
Hey @loic-simon I was indeed working on that at some point (I even have a branch for it, but can't find it ATM), but feel free to pick it up! The import parser might also need some refactoring while you're at it :) I'll try to review it in a timely manner 😆
pythongh-69605: Add math.integer to PyREPL module completer hardcoded…
pythongh-69605: Disable PyREPL module autocomplete fallback on regula…
gh-69605: fix PyREPL completions inserted for import statements with …
[3.15] gh-69605: fix PyREPL completions inserted for import statement…
gh-69605: PyREPL: insert "import" after "from foo <tab>" (#148445)