mirror of
https://github.com/frida/frida-python
synced 2026-06-08 14:16:17 +00:00
Use ParamSpec for better type hints
This commit is contained in:
committed by
Ole André Vadla Ravnås
parent
ec55dcb3bc
commit
9a3ec81843
+8
-3
@@ -38,6 +38,11 @@ if sys.version_info >= (3, 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
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user