Skip to content

gh-69605: fix PyREPL completions inserted for import statements with spaces#148629

Open
loic-simon wants to merge 2 commits intopython:mainfrom
loic-simon:pyrepl-module-completion-fix-space-in-imports
Open

gh-69605: fix PyREPL completions inserted for import statements with spaces#148629
loic-simon wants to merge 2 commits intopython:mainfrom
loic-simon:pyrepl-module-completion-fix-space-in-imports

Conversation

@loic-simon
Copy link
Copy Markdown
Contributor

@loic-simon loic-simon commented Apr 15, 2026

Re: #148445 (comment)

Note: I juste found an existing bug (on main) while testing things 😅

>>> from math .<tab>
>>> from math .ath.integer  # instead of `from math .integer` (valid syntax!)

Turn out the import parser already handled these cases well, the issue was that the parser only replaces the last entered word when inserting a suggestion, but inserted the whole import dotted name

So I added an additional step in ModuleCompleter.get_completions to reduce the completions to the portion to insert only

cc @tomasr8

Fix `from math .<tab>` inserting `from math .ath.integer` instead of `from math.integer`
@loic-simon loic-simon marked this pull request as ready for review April 15, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant