Skip to content

Commit 0806823

Browse files
committed
update packages, correct typehints
1 parent 8ede93a commit 0806823

File tree

10 files changed

+216
-226
lines changed

10 files changed

+216
-226
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,8 @@
639639
"@types/mocha": "^9.1.0",
640640
"@types/node": "^14.16.0",
641641
"@types/vscode": "^1.61.0",
642-
"@typescript-eslint/eslint-plugin": "^5.10.1",
643-
"@typescript-eslint/parser": "^5.10.1",
642+
"@typescript-eslint/eslint-plugin": "^5.10.2",
643+
"@typescript-eslint/parser": "^5.10.2",
644644
"@vscode/test-electron": "^2.1.1",
645645
"eslint": "^8.7.0",
646646
"eslint-config-prettier": "^8.3.0",
@@ -655,10 +655,10 @@
655655
"replace-in-file": "^6.3.2",
656656
"ts-loader": "^9.2.6",
657657
"typescript": "^4.5.5",
658-
"vsce": "^2.6.5",
658+
"vsce": "^2.6.6",
659659
"@vscode/debugadapter-testsupport": "^1.51.0",
660660
"vscode-dts": "^0.3.3",
661-
"webpack": "^5.67.0",
661+
"webpack": "^5.68.0",
662662
"webpack-cli": "^4.9.2"
663663
}
664664
}

poetry.lock

Lines changed: 171 additions & 176 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,29 @@ classifiers = [
4141

4242
[tool.poetry.dependencies]
4343
python = "^3.8"
44-
robotframework = ">=4.0.0"
44+
robotframework = "^4.0.0"
4545

4646

4747
[tool.poetry.dev-dependencies]
48-
isort = "^5.9.2"
49-
mypy = "^0.910"
50-
flake8 = "^3.9.2"
51-
black = "^21.6b0"
52-
pep8-naming = "^0.12.0"
53-
debugpy = "^1.3.0"
54-
pytest = "^6.2.4"
55-
pytest-asyncio = "^0.15.1"
56-
pytest-cov = "^2.12.1"
57-
coverage = "^5.5"
58-
coloredlogs = "^15.0.1"
59-
robotremoteserver = "^1.1"
60-
Cython = "^0.29.24"
61-
robotframework-robocop = "^1.7.1"
62-
robotframework-tidy = "^1.5.1"
63-
PyYAML = "^6.0"
64-
types-PyYAML = "^6.0"
65-
snakeviz = "^2.1.1"
66-
pytest-regressions = "^2.3.1"
48+
isort = "*"
49+
mypy = "*"
50+
flake8 = "*"
51+
black = "*"
52+
pep8-naming = "*"
53+
debugpy = "*"
54+
pytest = "*"
55+
pytest-asyncio = "*"
56+
pytest-cov = "*"
57+
coverage = "*"
58+
coloredlogs = "*"
59+
robotremoteserver = "*"
60+
Cython = "*"
61+
robotframework-robocop = "*"
62+
robotframework-tidy = "*"
63+
PyYAML = "*"
64+
types-PyYAML = "*"
65+
snakeviz = "*"
66+
pytest-regressions = "*"
6767

6868

6969
[tool.poetry-dynamic-versioning]
@@ -86,15 +86,15 @@ exclude = '''
8686
(
8787
/(
8888
\.eggs # exclude a few common directories in the
89-
| \.git # root of the project
89+
| \.git # root of the project
9090
| \.mypy_cache
9191
| \.tox
92-
| \.venv
92+
| \.venv
9393
| build
9494
| dist
9595
| out
9696
| robotcode/external
97-
)/
97+
)/
9898
)
9999
'''
100100

robotcode/jsonrpc2/protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ def _decorator(func: _F) -> Callable[[_F], _F]:
179179
raise TypeError(f"Not supported type {type(func)}.")
180180

181181
if isinstance(func, classmethod):
182-
f = cast(classmethod, func).__func__
182+
f = func.__func__
183183
elif isinstance(func, staticmethod):
184-
f = cast(staticmethod, func).__func__
184+
f = func.__func__
185185
else:
186186
f = func
187187

robotcode/language_server/common/lsp_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __repr__(self) -> str:
3434
or (f.default != dataclasses.MISSING and f.default != getattr(self, f.name))
3535
or (
3636
f.default_factory != dataclasses.MISSING # type: ignore
37-
and getattr(self, f.name) != f.default_factory() # type: ignore
37+
and getattr(self, f.name) != f.default_factory()
3838
)
3939
)
4040
)

robotcode/language_server/common/text_document.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import inspect
44
import io
55
import weakref
6-
from types import MethodType
76
from typing import Any, Awaitable, Callable, Dict, List, Optional, TypeVar, Union, cast
87

98
from ...utils.async_tools import Lock, create_sub_task
@@ -176,9 +175,7 @@ def __remove_cache_entry(self, ref: Any) -> None:
176175
def __get_cache_reference(self, entry: Callable[..., Any], /, *, add_remove: bool = True) -> weakref.ref[Any]:
177176

178177
if inspect.ismethod(entry):
179-
reference: weakref.ref[Any] = weakref.WeakMethod(
180-
cast(MethodType, entry), self.__remove_cache_entry if add_remove else None
181-
)
178+
reference: weakref.ref[Any] = weakref.WeakMethod(entry, self.__remove_cache_entry if add_remove else None)
182179
else:
183180
reference = weakref.ref(entry, self.__remove_cache_entry if add_remove else None)
184181

@@ -206,7 +203,7 @@ async def get_cache(
206203
if e.data is None:
207204
async with e.lock:
208205
if e.data is None:
209-
e.data = await entry(self, *args, **kwargs) # type: ignore
206+
e.data = await entry(self, *args, **kwargs)
210207

211208
return cast("_T", e.data)
212209

robotcode/utils/async_tools.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import weakref
1010
from collections import deque
1111
from concurrent.futures.thread import ThreadPoolExecutor
12-
from types import MethodType, TracebackType
12+
from types import TracebackType
1313
from typing import (
1414
Any,
1515
AsyncGenerator,
@@ -74,23 +74,23 @@ def remove_listener(ref: Any) -> None:
7474

7575
with self._lock:
7676
if inspect.ismethod(callback):
77-
self._listeners.add(weakref.WeakMethod(cast(MethodType, callback), remove_listener))
77+
self._listeners.add(weakref.WeakMethod(callback, remove_listener))
7878
else:
7979
self._listeners.add(weakref.ref(callback, remove_listener))
8080

8181
def remove(self, callback: _TCallable) -> None:
8282
with self._lock:
8383
try:
8484
if inspect.ismethod(callback):
85-
self._listeners.remove(weakref.WeakMethod(cast(MethodType, callback)))
85+
self._listeners.remove(weakref.WeakMethod(callback))
8686
else:
8787
self._listeners.remove(weakref.ref(callback))
8888
except KeyError:
8989
pass
9090

9191
def __contains__(self, obj: Any) -> bool:
9292
if inspect.ismethod(obj):
93-
return weakref.WeakMethod(cast(MethodType, obj)) in self._listeners
93+
return weakref.WeakMethod(obj) in self._listeners
9494
else:
9595
return weakref.ref(obj) in self._listeners
9696

@@ -664,7 +664,7 @@ def get_current_future_info() -> Optional[FutureInfo]:
664664
return _running_tasks[ct]
665665

666666

667-
def create_sub_task(coro: Coroutine[Any, Any, _T], *, name: Optional[str] = None) -> asyncio.Task[_T]:
667+
def create_sub_task(coro: Awaitable[_T], *, name: Optional[str] = None) -> asyncio.Task[_T]:
668668

669669
ct = get_current_future_info()
670670

robotcode/utils/dataclasses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def from_dict(value: Any, types: Union[Type[_T], Tuple[Type[_T], ...], None] = N
233233
k: from_dict(v, match_type_hints[k]) for k, v in match_value.items() if k in match_type_hints
234234
}
235235
try:
236-
return match(**params) # type: ignore
236+
return match(**params)
237237
except TypeError as ex:
238238
raise TypeError(f"Can't initialize class {repr(match)} with parameters {repr(params)}.") from ex
239239

robotcode/utils/event.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import inspect
44
import threading
55
import weakref
6-
from types import MethodType
76
from typing import (
87
Any,
98
Callable,
@@ -36,23 +35,23 @@ def remove_listener(ref: Any) -> None:
3635

3736
with self._lock:
3837
if inspect.ismethod(callback):
39-
self._listeners.add(weakref.WeakMethod(cast(MethodType, callback), remove_listener))
38+
self._listeners.add(weakref.WeakMethod(callback, remove_listener))
4039
else:
4140
self._listeners.add(weakref.ref(callback, remove_listener))
4241

4342
def remove(self, callback: _TCallable) -> None:
4443
with self._lock:
4544
try:
4645
if inspect.ismethod(callback):
47-
self._listeners.remove(weakref.WeakMethod(cast(MethodType, callback)))
46+
self._listeners.remove(weakref.WeakMethod(callback))
4847
else:
4948
self._listeners.remove(weakref.ref(callback))
5049
except KeyError:
5150
pass
5251

5352
def __contains__(self, obj: Any) -> bool:
5453
if inspect.ismethod(obj):
55-
return weakref.WeakMethod(cast(MethodType, obj)) in self._listeners
54+
return weakref.WeakMethod(obj) in self._listeners
5655
else:
5756
return weakref.ref(obj) in self._listeners
5857

robotcode/utils/logging.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import reprlib
88
import time
99
from enum import Enum
10-
from types import FunctionType, MethodType
1110
from typing import Any, Callable, List, Optional, Type, TypeVar, Union, cast, overload
1211

1312
__all__ = ["LoggingDescriptor"]
@@ -31,16 +30,16 @@ def _repr(o: Any) -> str:
3130

3231
def get_class_that_defined_method(meth: Callable[..., Any]) -> Optional[Type[Any]]:
3332
if inspect.ismethod(meth):
34-
for c in inspect.getmro(cast(MethodType, meth).__self__.__class__):
33+
for c in inspect.getmro(meth.__self__.__class__):
3534
if c.__dict__.get(meth.__name__) is meth:
3635
return c
37-
meth = cast(MethodType, meth).__func__ # fallback to __qualname__ parsing
36+
meth = meth.__func__ # fallback to __qualname__ parsing
3837
if inspect.isfunction(meth):
3938
class_name = meth.__qualname__.split(".<locals>", 1)[0].rsplit(".", 1)[0]
4039
try:
4140
cls = getattr(inspect.getmodule(meth), class_name)
4241
except AttributeError:
43-
cls = cast(FunctionType, meth).__globals__.get(class_name)
42+
cls = meth.__globals__.get(class_name)
4443
if isinstance(cls, type):
4544
return cls
4645
return None
@@ -120,7 +119,7 @@ def __init_logger(self) -> LoggingDescriptor:
120119
if self.__func is not None:
121120

122121
if isinstance(self.__func, staticmethod):
123-
returned_logger = cast(staticmethod, self.__func).__func__()
122+
returned_logger = self.__func.__func__()
124123
else:
125124
returned_logger = self.__func()
126125

0 commit comments

Comments
 (0)