Skip to content

Commit 5a4a1f5

Browse files
Typing fixes.
1 parent d0da43e commit 5a4a1f5

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

prompt_toolkit/application/dummy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def run(self, pre_run: Optional[Callable[[], None]] = None,
2222
set_exception_handler: bool = True) -> None:
2323
raise NotImplementedError('A DummyApplication is not supposed to run.')
2424

25-
async def run_async(self, pre_run: Optional[Callable[[], None]] = None) -> None:
25+
async def run_async(self, pre_run: Optional[Callable[[], None]] = None,
26+
set_exception_handler: bool = True) -> None:
2627
raise NotImplementedError('A DummyApplication is not supposed to run.')
2728

2829
async def run_system_command(

prompt_toolkit/completion/nested.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Nestedcompleter for completion of hierarchical data structures.
33
"""
4-
from typing import Dict, Iterable, Mapping, Optional, Set, Union
4+
from typing import Any, Dict, Iterable, Mapping, Optional, Set, Union
55

66
from prompt_toolkit.completion import CompleteEvent, Completer, Completion
77
from prompt_toolkit.completion.word_completer import WordCompleter
@@ -11,7 +11,8 @@
1111
'NestedCompleter'
1212
]
1313

14-
NestedDict = Mapping[str, Union['NestedDict', Set[str], None, Completer]]
14+
# NestedDict = Mapping[str, Union['NestedDict', Set[str], None, Completer]]
15+
NestedDict = Mapping[str, Union[Any, Set[str], None, Completer]]
1516

1617

1718
class NestedCompleter(Completer):

prompt_toolkit/key_binding/bindings/emacs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# pylint: disable=function-redefined
2+
from typing import Dict, Union
3+
24
from prompt_toolkit.application.current import get_app
35
from prompt_toolkit.buffer import Buffer, SelectionType, indent, unindent
46
from prompt_toolkit.completion import CompleteEvent
@@ -14,6 +16,7 @@
1416
shift_selection_mode,
1517
vi_search_direction_reversed,
1618
)
19+
from prompt_toolkit.key_binding.key_bindings import Binding
1720
from prompt_toolkit.key_binding.key_processor import KeyPressEvent
1821
from prompt_toolkit.keys import Keys
1922

@@ -395,7 +398,7 @@ def unshift_move(event: E) -> None:
395398
return
396399

397400
# the other keys are handled through their readline command
398-
key_to_command = {
401+
key_to_command: Dict[Union[Keys, str], str] = {
399402
Keys.ShiftLeft: 'backward-char',
400403
Keys.ShiftRight: 'forward-char',
401404
Keys.ShiftHome: 'beginning-of-line',
@@ -412,7 +415,10 @@ def unshift_move(event: E) -> None:
412415
except KeyError:
413416
pass
414417
else: # (`else` is not really needed here.)
415-
handler(event)
418+
if not isinstance(handler, Binding):
419+
# (It should always be a normal callable here, for these
420+
# commands.)
421+
handler(event)
416422

417423
@handle('s-left', filter= ~has_selection)
418424
@handle('s-right', filter= ~has_selection)

prompt_toolkit/layout/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __setitem__(self, index: Union[int, slice], value: Union[_T, Iterable[_T]])
4747
if isinstance(value, tuple): # In case of `OneStyleAndTextTuple`.
4848
value = cast('List[_T]', [value])
4949

50-
super().__setitem__(index, explode_text_fragments(value))
50+
super().__setitem__(index, explode_text_fragments(cast('Iterable[_T]', value)))
5151

5252

5353
def explode_text_fragments(fragments: Iterable[_T]) -> _ExplodedList[_T]:

0 commit comments

Comments
 (0)