Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implements #446, it's essentially the same workaround (using the internal APIs of
_pyrepl
), but I needed to make some further tweaks to get it working.cli.py
andrlcompleter.py
._pyrepl
package. It's honestly quite nice that this is a drop-in enough replacement. The history file works as expected without any tweaks._setup()
function that resets the completer, regardless of what you have set previously. So I had to add a call to that so that ourset_completer()
call would stick.type: ignore
added to the imports.Incidentally, I did this by factoring out a simple
interact()
API that can be implemented viacode
or_pyrepl
, and that makes it trivial to substitute in theprompt_toolkit
implementation fromcontrib.ptdrgn
. So I took the opportunity to simplify that script in a follow-up commit.I'm not entirely sure that this is good overall. It does work on my build of Python 3.13, and it is genuinely nice to use. It's not like Python is making frequent releases, but it does seem totally possible for these internals to change, and that would be a pain to handle.