Repository navigation
[WIP] Upgrade to prompt_toolkit 2.0 - #10964
jonathanslenders wants to merge 1 commit into
Conversation
b266db4 to
3607661
Compare
|
See also: prompt-toolkit/python-prompt-toolkit#568 |
| if hasattr(self.pt_cli, 'pre_run_callables'): | ||
| self.pt_cli.pre_run_callables.append(set_doc) | ||
| self.pt_app.application.buffer.document = Document(s) | ||
| if hasattr(self.pt_app.application, 'pre_run_callables'): |
There was a problem hiding this comment.
IIRC this hasattr() check was for compatibility with older prompt_toolkit versions. As this will require 2.x anyway, we can probably remove it and only use pre_run_callables.
There was a problem hiding this comment.
Right. Fixed now.
There was a problem hiding this comment.
What is actually the use for this pre_prompt function? What is rl_next_input?
There was a problem hiding this comment.
Various functions can set some text to appear at the next prompt, e.g. I can run %load foo.py to get the contents of foo.py at the next prompt. There's also %recall which can retrieve entries from history. That gets stored in rl_next_input and then inserted when the next prompt is being prepared.
| # some configuration options have changed. | ||
| # """ | ||
| # if self.pt_app: | ||
| # self.pt_app.layout = create_prompt_layout(**self._extra_prompt_options()) |
There was a problem hiding this comment.
Is this no longer necessary, or do we need a different way of doing it? There are some settings we can change at runtime, and we needed to do this for them to take effect.
There was a problem hiding this comment.
This is indeed no longer necessary, unless I miss something. All the extra_prompt_options are passed to each prompt() call. This should update them every time.
|
Thanks for making a start on this! I remember you said that PT 2 would add a way to do tab completions on the main thread. I'm looking forward to this, because we've had a number of reports of completion problems resulting from it using a separate thread. Is that API in place? Will it be easy to integrate? |
3607661 to
a0283ba
Compare
|
prompt_toolkit 2.0 does indeed support synchronous completion. This is even the default, because apparently, that's what most people want, and is the easiest. Asynchronous completion is possible by passing |
a0283ba to
fb277cc
Compare
|
Great, so we should get synchronous completion without doing anything else. |
fb277cc to
6687b4c
Compare
6687b4c to
c4f76bb
Compare
c4f76bb to
7d6a0f3
Compare
7d6a0f3 to
f886657
Compare
|
Hi @jonathanslenders ! How's v2 coming along? :-) |
|
Hi @takluyver, |
|
My normal inclination would be to do this for 7.0, but I know that people have had problems with tab completion running in a separate thread, and so we may end up doing it as a bugfix, possibly even back to 5.x. The remaining Python 2 users now can't go past 5.x, so there's some extra pressure to backport things. |
|
I'm not coming to Pycon (I'm avoiding travelling to the US as a kind of personal protest), but I'm hoping to be at EuroPython later this year. |
|
Hello, Is there any release date of Thanks a lot for both your projects, there are just amazing and really useful! |
|
If we want to make a smallish-7.x release that simply update to |
0eb9b78 to
e04a799
Compare
e04a799 to
deab448
Compare
|
Seems like Hope to see an IPython integration soon :) |
|
Nice one @jonathanslenders :-) Are you going to get back to this PR, or would you rather someone else picked it up? And well spotted @gpotter2 - it hasn't even been out one hour yet! |
|
@takluyver: I'm not sure I have the time for all the required testing. I think all the relevant changes are done, so maybe somebody can take it from here. A couple of things:
|
| if self.pt_cli: | ||
| self.pt_cli.print_tokens(tokens) | ||
| if self.pt_app: | ||
| self.pt_app.print_tokens(tokens) # XXX |
There was a problem hiding this comment.
Is there any replacement for the print_tokens() method?
There was a problem hiding this comment.
Nvm, found it from the file below :-)
|
I've rebased and fixed up a few problems in #11177. |
|
@takluyver Thanks a lot for your work ! |
|
Any reason to keep this PR open ? |
|
Nope, it was superseded by #11177. |

There are still some bugs and a couple of things to fix.