|
33 | 33 | import builtins |
34 | 34 |
|
35 | 35 | from enum import Enum |
36 | | -from typing import Any, Dict, Iterator, List, Match, NoReturn, Set, Union, Tuple |
| 36 | +from typing import ( |
| 37 | + Any, |
| 38 | + Dict, |
| 39 | + Iterator, |
| 40 | + List, |
| 41 | + Match, |
| 42 | + Set, |
| 43 | + Union, |
| 44 | + Tuple, |
| 45 | + Type, |
| 46 | + Sequence, |
| 47 | +) |
37 | 48 | from . import inspection |
38 | 49 | from . import line as lineparts |
39 | 50 | from .line import LinePart |
@@ -180,15 +191,15 @@ def few_enough_underscores(current, match) -> bool: |
180 | 191 | return not match.startswith("_") |
181 | 192 |
|
182 | 193 |
|
183 | | -def method_match_none(word, size, text) -> bool: |
| 194 | +def method_match_none(word: str, size: int, text: str) -> bool: |
184 | 195 | return False |
185 | 196 |
|
186 | 197 |
|
187 | | -def method_match_simple(word, size, text) -> bool: |
| 198 | +def method_match_simple(word: str, size: int, text: str) -> bool: |
188 | 199 | return word[:size] == text |
189 | 200 |
|
190 | 201 |
|
191 | | -def method_match_substring(word, size, text) -> bool: |
| 202 | +def method_match_substring(word: str, size: int, text: str) -> bool: |
192 | 203 | return text in word |
193 | 204 |
|
194 | 205 |
|
@@ -265,16 +276,20 @@ def shown_before_tab(self) -> bool: |
265 | 276 | class CumulativeCompleter(BaseCompletionType): |
266 | 277 | """Returns combined matches from several completers""" |
267 | 278 |
|
268 | | - def __init__(self, completers, mode=AutocompleteModes.SIMPLE) -> None: |
| 279 | + def __init__( |
| 280 | + self, |
| 281 | + completers: Sequence[BaseCompletionType], |
| 282 | + mode: AutocompleteModes = AutocompleteModes.SIMPLE, |
| 283 | + ) -> None: |
269 | 284 | if not completers: |
270 | 285 | raise ValueError( |
271 | 286 | "CumulativeCompleter requires at least one completer" |
272 | 287 | ) |
273 | | - self._completers = completers |
| 288 | + self._completers: Sequence[BaseCompletionType] = completers |
274 | 289 |
|
275 | 290 | super().__init__(True, mode) |
276 | 291 |
|
277 | | - def locate(self, current_offset: int, line: str) -> Union[None, NoReturn]: |
| 292 | + def locate(self, current_offset, line): |
278 | 293 | for completer in self._completers: |
279 | 294 | return_value = completer.locate(current_offset, line) |
280 | 295 | if return_value is not None: |
@@ -573,7 +588,7 @@ def matches(self, cursor_offset, line, **kwargs) -> Union[Set, None]: |
573 | 588 | import jedi |
574 | 589 | except ImportError: |
575 | 590 |
|
576 | | - class MultilineJediCompletion(BaseCompletionType): |
| 591 | + class MultilineJediCompletion(BaseCompletionType): # type: ignore [no-redef] |
577 | 592 | def matches(self, cursor_offset, line, **kwargs) -> None: |
578 | 593 | return None |
579 | 594 |
|
@@ -630,7 +645,7 @@ def locate(self, cursor_offset: int, line: str) -> LinePart: |
630 | 645 | end = cursor_offset |
631 | 646 | return LinePart(start, end, line[start:end]) |
632 | 647 |
|
633 | | - class MultilineJediCompletion(JediCompletion): |
| 648 | + class MultilineJediCompletion(JediCompletion): # type: ignore [no-redef] |
634 | 649 | def matches(self, cursor_offset, line, **kwargs) -> Union[Set, None]: |
635 | 650 | if "current_block" not in kwargs or "history" not in kwargs: |
636 | 651 | return None |
|
0 commit comments