Show More
@@ -129,7 +129,7 b' import warnings' | |||
|
129 | 129 | |
|
130 | 130 | from contextlib import contextmanager |
|
131 | 131 | from importlib import import_module |
|
132 | from typing import Iterator, List | |
|
132 | from typing import Iterator, List, Tuple, Iterable, Union | |
|
133 | 133 | from types import SimpleNamespace |
|
134 | 134 | |
|
135 | 135 | from traitlets.config.configurable import Configurable |
@@ -365,7 +365,7 b' class Completion:' | |||
|
365 | 365 | ``IPython.python_matches``, ``IPython.magics_matches``...). |
|
366 | 366 | """ |
|
367 | 367 | |
|
368 | def __init__(self, start: int, end: int, text: str, *, type: str=None, _origin=''): | |
|
368 | def __init__(self, start: int, end: int, text: str, *, type: str=None, _origin='') -> None: | |
|
369 | 369 | warnings.warn("``Completion`` is a provisional API (as of IPython 6.0). " |
|
370 | 370 | "It may change without warnings. " |
|
371 | 371 | "Use in corresponding context manager.", |
@@ -398,7 +398,7 b' class Completion:' | |||
|
398 | 398 | return hash((self.start, self.end, self.text)) |
|
399 | 399 | |
|
400 | 400 | |
|
401 |
_IC = Itera |
|
|
401 | _IC = Iterable[Completion] | |
|
402 | 402 | |
|
403 | 403 | |
|
404 | 404 | def _deduplicate_completions(text: str, completions: _IC)-> _IC: |
@@ -736,12 +736,12 b' def match_dict_keys(keys: List[str], prefix: str, delims: str):' | |||
|
736 | 736 | |
|
737 | 737 | Parameters |
|
738 | 738 | ========== |
|
739 |
|
|
|
740 |
|
|
|
741 |
|
|
|
742 |
|
|
|
743 |
|
|
|
744 |
|
|
|
739 | keys: | |
|
740 | list of keys in dictionary currently being completed. | |
|
741 | prefix: | |
|
742 | Part of the text already typed by the user. e.g. `mydict[b'fo` | |
|
743 | delims: | |
|
744 | String of delimiters to consider when finding the current key. | |
|
745 | 745 | |
|
746 | 746 | Returns |
|
747 | 747 | ======= |
@@ -800,7 +800,7 b' def match_dict_keys(keys: List[str], prefix: str, delims: str):' | |||
|
800 | 800 | return quote, token_start, matched |
|
801 | 801 | |
|
802 | 802 | |
|
803 |
def cursor_to_position(text: |
|
|
803 | def cursor_to_position(text:str, line:int, column:int)->int: | |
|
804 | 804 | """ |
|
805 | 805 | |
|
806 | 806 | Convert the (line,column) position of the cursor in text to an offset in a |
@@ -830,7 +830,7 b' def cursor_to_position(text:int, line:int, column:int)->int:' | |||
|
830 | 830 | |
|
831 | 831 | return sum(len(l) + 1 for l in lines[:line]) + column |
|
832 | 832 | |
|
833 |
def position_to_cursor(text:str, offset:int)-> |
|
|
833 | def position_to_cursor(text:str, offset:int)->Tuple[int, int]: | |
|
834 | 834 | """ |
|
835 | 835 | Convert the position of the cursor in text (0 indexed) to a line |
|
836 | 836 | number(0-indexed) and a column number (0-indexed) pair |
@@ -1828,7 +1828,7 b' class IPCompleter(Completer):' | |||
|
1828 | 1828 | return self._complete(line_buffer=line_buffer, cursor_pos=cursor_pos, text=text, cursor_line=0)[:2] |
|
1829 | 1829 | |
|
1830 | 1830 | def _complete(self, *, cursor_line, cursor_pos, line_buffer=None, text=None, |
|
1831 |
full_text=None, return_jedi_results=True) -> |
|
|
1831 | full_text=None, return_jedi_results=True) -> Tuple[str, List[str], List[str], Iterable[_FakeJediCompletion]]: | |
|
1832 | 1832 | """ |
|
1833 | 1833 | |
|
1834 | 1834 | Like complete but can also returns raw jedi completions as well as the |
@@ -1868,7 +1868,7 b' class IPCompleter(Completer):' | |||
|
1868 | 1868 | for meth in (self.unicode_name_matches, back_latex_name_matches, back_unicode_name_matches): |
|
1869 | 1869 | name_text, name_matches = meth(base_text) |
|
1870 | 1870 | if name_text: |
|
1871 |
return name_text, name_matches, [meth.__qualname__]*len(name_matches), |
|
|
1871 | return name_text, name_matches, [meth.__qualname__]*len(name_matches), () | |
|
1872 | 1872 | |
|
1873 | 1873 | |
|
1874 | 1874 | # If no line buffer is given, assume the input text is all there was |
@@ -1922,12 +1922,12 b' class IPCompleter(Completer):' | |||
|
1922 | 1922 | filtered_matches.add(m) |
|
1923 | 1923 | seen.add(t) |
|
1924 | 1924 | |
|
1925 | filtered_matches = sorted( | |
|
1925 | _filtered_matches = sorted( | |
|
1926 | 1926 | set(filtered_matches), key=lambda x: completions_sorting_key(x[0])) |
|
1927 | 1927 | |
|
1928 | matches = [m[0] for m in filtered_matches] | |
|
1929 | origins = [m[1] for m in filtered_matches] | |
|
1928 | _matches = [m[0] for m in _filtered_matches] | |
|
1929 | origins = [m[1] for m in _filtered_matches] | |
|
1930 | 1930 | |
|
1931 | self.matches = matches | |
|
1931 | self.matches = _matches | |
|
1932 | 1932 | |
|
1933 | return text, matches, origins, completions | |
|
1933 | return text, _matches, origins, completions |
@@ -28,22 +28,8 b' from IPython.utils.py3compat import bytes_to_str' | |||
|
28 | 28 | from IPython.utils.sysinfo import get_sys_info |
|
29 | 29 | from IPython.utils.tempdir import TemporaryDirectory |
|
30 | 30 | |
|
31 | try: | |
|
32 | # Python >= 3.3 | |
|
33 | from subprocess import TimeoutExpired | |
|
34 | def popen_wait(p, timeout): | |
|
35 | return p.wait(timeout) | |
|
36 | except ImportError: | |
|
37 | class TimeoutExpired(Exception): | |
|
38 | pass | |
|
39 | def popen_wait(p, timeout): | |
|
40 | """backport of Popen.wait from Python 3""" | |
|
41 | for i in range(int(10 * timeout)): | |
|
42 | if p.poll() is not None: | |
|
43 | return | |
|
44 | time.sleep(0.1) | |
|
45 | if p.poll() is None: | |
|
46 | raise TimeoutExpired | |
|
31 | def popen_wait(p, timeout): | |
|
32 | return p.wait(timeout) | |
|
47 | 33 | |
|
48 | 34 | class TestController(object): |
|
49 | 35 | """Run tests in a subprocess |
General Comments 0
You need to be logged in to leave comments.
Login now