Skip to content

Commit

Permalink
Use ParamSpec for better type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
deltaclock authored and oleavr committed Oct 10, 2024
1 parent ec55dcb commit 9a3ec81
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions frida/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
else:
from typing_extensions import NotRequired

if sys.version_info >= (3, 10):
from typing import ParamSpec
else:
from typing_extensions import ParamSpec

from . import _frida

_device_manager = None
Expand Down Expand Up @@ -73,11 +78,11 @@ def _filter_missing_kwargs(d: MutableMapping[Any, Any]) -> None:


R = TypeVar("R")
P = ParamSpec("P")


def cancellable(f: Callable[..., R]) -> Callable[..., R]:
def cancellable(f: Callable[P, R]) -> Callable[P, R]:
@functools.wraps(f)
def wrapper(*args: Any, **kwargs: Any) -> R:
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
cancellable = kwargs.pop("cancellable", None)
if cancellable is not None:
with cancellable:

Check failure on line 88 in frida/core.py

View workflow job for this annotation

GitHub Actions / mypy

"object" has no attribute "__enter__" [attr-defined]

Check failure on line 88 in frida/core.py

View workflow job for this annotation

GitHub Actions / mypy

"object" has no attribute "__exit__" [attr-defined]
Expand Down

0 comments on commit 9a3ec81

Please sign in to comment.