Skip to content

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

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

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

Conversation

@loic-simon

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

Copy link
Copy Markdown
Contributor

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 REPL 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
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jul 25, 2026
Comment on lines +1 to +2
Fix :term:`REPL` completions inserted incorrectly when there was spaces in
import statements.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Fix :term:`REPL` completions inserted incorrectly when there was spaces in
import statements.
Fix :term:`REPL` completions inserted incorrectly when there were spaces in
import statements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants