◐ Shell
clean mode source ↗

gh-69605: fix PyREPL completions inserted for import statements with spaces by loic-simon · Pull Request #148629 · python/cpython

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