Skip to content

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

Merged
ambv merged 2 commits into
python:mainfrom
loic-simon:pyrepl-module-completion-fix-space-in-imports
Oct 20, 2026
Merged

ambv merged 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

@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.

Fix `from math .<tab>` inserting `from math .ath.integer` instead of `from math.integer`
@ambv
ambv force-pushed the pyrepl-module-completion-fix-space-in-imports branch from 799bd64 to d605a25 Compare October 20, 2026 21:03
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 20, 2026
@ambv ambv added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 20, 2026
@ambv
ambv merged commit 488ce0f into python:main Oct 20, 2026
68 of 72 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @loic-simon for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @loic-simon and @ambv, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 488ce0f050d798ff0553ac6b52e7bccb73b60017 3.14

@bedevere-app

bedevere-app Bot commented Oct 20, 2026

Copy link
Copy Markdown

GH-159989 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 20, 2026
ambv pushed a commit that referenced this pull request Oct 21, 2026
…s with spaces (GH-148629) (#159989)

Fix `from math .<tab>` inserting `from math .ath.integer` instead of `from math.integer`
(cherry picked from commit 488ce0f)

Co-authored-by: Loïc Simon <loic.simon@napta.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport to 3.14 bugs and security fixes stale Stale PR or inactive for long period of time. type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants