|
13 | 13 | from enum import Enum |
14 | 14 | from types import FrameType, TracebackType |
15 | 15 | from typing import ( |
16 | | - Dict, |
17 | 16 | Any, |
18 | 17 | Iterable, |
| 18 | + Dict, |
19 | 19 | List, |
20 | 20 | Optional, |
21 | 21 | Sequence, |
22 | 22 | Tuple, |
23 | | - Union, |
24 | 23 | Type, |
| 24 | + Union, |
25 | 25 | ) |
26 | 26 | from .._typing_compat import Literal |
27 | 27 |
|
|
55 | 55 | Interp, |
56 | 56 | code_finished_will_parse, |
57 | 57 | ) |
58 | | -from .manual_readline import edit_keys, cursor_on_closing_char_pair |
| 58 | +from .manual_readline import ( |
| 59 | + edit_keys, |
| 60 | + cursor_on_closing_char_pair, |
| 61 | + AbstractEdits, |
| 62 | +) |
59 | 63 | from .parse import parse as bpythonparse, func_for_letter, color_for_letter |
60 | 64 | from .preprocess import preprocess |
61 | 65 | from .. import __version__ |
@@ -105,15 +109,20 @@ class FakeStdin: |
105 | 109 | In user code, sys.stdin.read() asks the user for interactive input, |
106 | 110 | so this class returns control to the UI to get that input.""" |
107 | 111 |
|
108 | | - def __init__(self, coderunner, repl, configured_edit_keys=None): |
| 112 | + def __init__( |
| 113 | + self, |
| 114 | + coderunner: CodeRunner, |
| 115 | + repl: "BaseRepl", |
| 116 | + configured_edit_keys: Optional[AbstractEdits] = None, |
| 117 | + ): |
109 | 118 | self.coderunner = coderunner |
110 | 119 | self.repl = repl |
111 | 120 | self.has_focus = False # whether FakeStdin receives keypress events |
112 | 121 | self.current_line = "" |
113 | 122 | self.cursor_offset = 0 |
114 | 123 | self.old_num_lines = 0 |
115 | | - self.readline_results = [] |
116 | | - if configured_edit_keys: |
| 124 | + self.readline_results: List[str] = [] |
| 125 | + if configured_edit_keys is not None: |
117 | 126 | self.rl_char_sequences = configured_edit_keys |
118 | 127 | else: |
119 | 128 | self.rl_char_sequences = edit_keys |
@@ -236,7 +245,7 @@ class ReevaluateFakeStdin: |
236 | 245 | """Stdin mock used during reevaluation (undo) so raw_inputs don't have to |
237 | 246 | be reentered""" |
238 | 247 |
|
239 | | - def __init__(self, fakestdin, repl): |
| 248 | + def __init__(self, fakestdin: FakeStdin, repl: "BaseRepl"): |
240 | 249 | self.fakestdin = fakestdin |
241 | 250 | self.repl = repl |
242 | 251 | self.readline_results = fakestdin.readline_results[:] |
|
0 commit comments