Skip to content

Commit ae21ebd

Browse files
Changes for being compatible with the prompt-toolkit Callback refactoring.
1 parent 36f96f4 commit ae21ebd

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

ptpython/history_browser.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from prompt_toolkit.layout.toolbars import ArgToolbar, SearchToolbar
2525
from prompt_toolkit.layout.toolbars import TokenListToolbar
2626
from prompt_toolkit.layout.utils import token_list_to_text
27-
from prompt_toolkit.utils import Callback
2827
from pygments.lexers import RstLexer
2928
from pygments.token import Token
3029

@@ -530,7 +529,7 @@ def create_history_application(python_input, original_document):
530529
"""
531530
history_mapping = HistoryMapping(python_input.history, original_document)
532531

533-
def default_buffer_pos_changed():
532+
def default_buffer_pos_changed(_):
534533
""" When the cursor changes in the default buffer. Synchronize with
535534
history buffer. """
536535
# Only when this buffer has the focus.
@@ -549,7 +548,7 @@ def default_buffer_pos_changed():
549548
history_buffer.cursor_position = \
550549
history_buffer.document.translate_row_col_to_index(history_lineno, 0)
551550

552-
def history_buffer_pos_changed():
551+
def history_buffer_pos_changed(_):
553552
""" When the cursor changes in the history buffer. Synchronize. """
554553
# Only when this buffer has the focus.
555554
if buffer_mapping.focus_stack[-1] == HISTORY_BUFFER:
@@ -564,14 +563,14 @@ def history_buffer_pos_changed():
564563

565564
history_buffer = Buffer(
566565
initial_document=Document(history_mapping.concatenated_history),
567-
on_cursor_position_changed=Callback(history_buffer_pos_changed),
566+
on_cursor_position_changed=history_buffer_pos_changed,
568567
accept_action=AcceptAction(
569568
lambda cli, buffer: cli.set_return_value(default_buffer.document)),
570569
read_only=True)
571570

572571
default_buffer = Buffer(
573572
initial_document=history_mapping.get_new_document(),
574-
on_cursor_position_changed=Callback(default_buffer_pos_changed),
573+
on_cursor_position_changed=default_buffer_pos_changed,
575574
read_only=True)
576575

577576
help_buffer = Buffer(

ptpython/python_input.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from prompt_toolkit.layout.lexers import PygmentsLexer
2323
from prompt_toolkit.shortcuts import create_output
2424
from prompt_toolkit.styles import DynamicStyle
25-
from prompt_toolkit.utils import Callback, is_windows
25+
from prompt_toolkit.utils import is_windows
2626
from prompt_toolkit.validation import ConditionalValidator
2727

2828
from .completer import PythonCompleter
@@ -520,9 +520,9 @@ def create_application(self):
520520
on_exit=self._on_exit,
521521
style=DynamicStyle(lambda: self._current_style),
522522
get_title=lambda: self.terminal_title,
523-
on_initialize=Callback(self._on_cli_initialize),
523+
on_initialize=self._on_cli_initialize,
524524
on_start=self._on_start,
525-
on_input_timeout=Callback(self._on_input_timeout))
525+
on_input_timeout=self._on_input_timeout)
526526

527527
def _create_buffer(self):
528528
"""
@@ -555,7 +555,7 @@ def _on_cli_initialize(self, cli):
555555
Called when a CommandLineInterface has been created.
556556
"""
557557
# Synchronize PythonInput state with the CommandLineInterface.
558-
def synchronize():
558+
def synchronize(_=None):
559559
if self.vi_mode:
560560
cli.editing_mode = EditingMode.VI
561561
else:

ptpython/repl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from prompt_toolkit.layout.utils import token_list_width
1919
from prompt_toolkit.shortcuts import create_asyncio_eventloop
2020
from prompt_toolkit.styles import style_from_pygments
21-
from prompt_toolkit.utils import DummyContext, Callback
21+
from prompt_toolkit.utils import DummyContext
2222

2323
from .python_input import PythonInput, PythonCommandLineInterface
2424
from .eventloop import create_eventloop
@@ -44,7 +44,7 @@ def __init__(self, *a, **kw):
4444
kw.update({
4545
'_accept_action': AcceptAction.run_in_terminal(
4646
handler=self._process_document, render_cli_done=True),
47-
'_on_start': Callback(self._on_start),
47+
'_on_start': self._on_start,
4848
'_on_exit': AbortAction.RETURN_NONE,
4949
})
5050

0 commit comments

Comments
 (0)