Skip to content

Commit b536803

Browse files
authored
Merge pull request pappasam#258 from dimbleby/stricter-typing
pygls 1.0.1, stricter typing
2 parents ab5605e + 3e27c8b commit b536803

File tree

5 files changed

+356
-353
lines changed

5 files changed

+356
-353
lines changed

jedi_language_server/initialization_options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class CodeAction(Model):
3434
class Completion(Model):
3535
disable_snippets: bool = False
3636
resolve_eagerly: bool = False
37-
ignore_patterns: List[Pattern] = []
37+
# <https://github.com/pydantic/pydantic/issues/2636>
38+
ignore_patterns: List[Pattern] = [] # type: ignore[type-arg]
3839

3940

4041
class Diagnostics(Model):

jedi_language_server/jedi_utils.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import threading
1010
from ast import PyCF_ONLY_AST
1111
from inspect import Parameter
12-
from typing import Dict, Iterator, List, Optional, Tuple
12+
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple
1313

1414
import docstring_to_markdown
1515
import jedi.api.errors
@@ -37,25 +37,35 @@
3737
from .initialization_options import HoverDisableOptions, InitializationOptions
3838
from .type_map import get_lsp_completion_type, get_lsp_symbol_type
3939

40+
if sys.version_info < (3, 10):
41+
from typing_extensions import ParamSpec
42+
else:
43+
from typing import ParamSpec
4044

41-
def debounce(interval_s, keyed_by=None):
45+
46+
P = ParamSpec("P")
47+
48+
49+
def debounce(
50+
interval_s: int, keyed_by: Optional[str] = None
51+
) -> Callable[[Callable[P, None]], Callable[P, None]]:
4252
"""Debounce calls to this function until interval_s seconds have passed.
4353
4454
Decorator copied from https://github.com/python-lsp/python-lsp-
4555
server
4656
"""
4757

48-
def wrapper(func):
49-
timers = {}
58+
def wrapper(func: Callable[P, None]) -> Callable[P, None]:
59+
timers: Dict[Any, threading.Timer] = {}
5060
lock = threading.Lock()
5161

5262
@functools.wraps(func)
53-
def debounced(*args, **kwargs):
63+
def debounced(*args: P.args, **kwargs: P.kwargs) -> None:
5464
sig = inspect.signature(func)
5565
call_args = sig.bind(*args, **kwargs)
5666
key = call_args.arguments[keyed_by] if keyed_by else None
5767

58-
def run():
68+
def run() -> None:
5969
with lock:
6070
del timers[key]
6171
return func(*args, **kwargs)

mypy.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
[mypy]
22
plugins = pydantic.mypy
3+
strict = True
4+
enable_error_code = ignore-without-code,redundant-expr,truthy-bool
35

46
[mypy-jedi.*]
57
ignore_missing_imports = True
6-
7-
[mypy-pygls.*]
8-
no_implicit_reexport = False

0 commit comments

Comments
 (0)