##// END OF EJS Templates
MISC docs, cleanup and typing (in progress).
Matthias Bussonnier -
Show More
@@ -156,7 +156,7 b" frontend_flags['i'] = ("
156 156 flags.update(frontend_flags)
157 157
158 158 aliases = dict(base_aliases)
159 aliases.update(shell_aliases)
159 aliases.update(shell_aliases) # type: ignore[arg-type]
160 160
161 161 #-----------------------------------------------------------------------------
162 162 # Main classes and functions
@@ -180,7 +180,7 b' class LocateIPythonApp(BaseIPythonApplication):'
180 180 class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):
181 181 name = u'ipython'
182 182 description = usage.cl_usage
183 crash_handler_class = IPAppCrashHandler
183 crash_handler_class = IPAppCrashHandler # typing: ignore[assignment]
184 184 examples = _examples
185 185
186 186 flags = flags
@@ -163,11 +163,11 b' def create_ipython_shortcuts(shell, for_all_platforms: bool = False):'
163 163 return _preceding_text_cache[pattern]
164 164
165 165 if callable(pattern):
166
167 166 def _preceding_text():
168 167 app = get_app()
169 168 before_cursor = app.current_buffer.document.current_line_before_cursor
170 return bool(pattern(before_cursor))
169 # mypy can't infer if(callable): https://github.com/python/mypy/issues/3603
170 return bool(pattern(before_cursor)) # type: ignore[operator]
171 171
172 172 else:
173 173 m = re.compile(pattern)
@@ -1,7 +1,7 b''
1 1 import re
2 2 import tokenize
3 3 from io import StringIO
4 from typing import Callable, List, Optional, Union
4 from typing import Callable, List, Optional, Union, Generator, Tuple
5 5
6 6 from prompt_toolkit.buffer import Buffer
7 7 from prompt_toolkit.key_binding import KeyPressEvent
@@ -19,7 +19,11 b' def _get_query(document: Document):'
19 19
20 20
21 21 class NavigableAutoSuggestFromHistory(AutoSuggestFromHistory):
22 """ """
22 """
23 A subclass of AutoSuggestFromHistory that allow navigation to next/previous
24 suggestion from history. To do so it remembers the current position, but it
25 state need to carefully be cleared on the right events.
26 """
23 27
24 28 def __init__(
25 29 self,
@@ -56,7 +60,24 b' class NavigableAutoSuggestFromHistory(AutoSuggestFromHistory):'
56 60
57 61 def _find_match(
58 62 self, text: str, skip_lines: float, history: History, previous: bool
59 ):
63 ) -> Generator[Tuple[str, float], None, None]:
64 """
65 text: str
66
67 skip_lines: float
68 float is used as the base value is +inf
69
70 Yields
71 ------
72 Tuple with:
73 str:
74 current suggestion.
75 float:
76 will actually yield only ints, which is passed back via skip_lines,
77 which may be a +inf (float)
78
79
80 """
60 81 line_number = -1
61 82 for string in reversed(list(history.get_strings())):
62 83 for line in reversed(string.splitlines()):
General Comments 0
You need to be logged in to leave comments. Login now