Skip to content

Commit ccf9411

Browse files
authored
[uWSGI] Use a TypeVarTuple in uwsgidecorators.thread (#11128)
1 parent 9023424 commit ccf9411

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

stubs/uWSGI/@tests/stubtest_allowlist.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,3 @@
55
uwsgidecorators.erlang
66
# This should really only be internal API, so we don't export it
77
uwsgidecorators.harakiri.real_call
8-
9-
# Error: is inconsistent
10-
# ======================
11-
# This is a limitation of ParamSpec, we can't specify that the
12-
# the ParamSpec does have no keyword arguments, but we need the
13-
# ParamSpec to properly annotate this decorator
14-
uwsgidecorators.thread.__call__

stubs/uWSGI/uwsgidecorators.pyi

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from collections.abc import Callable
22
from typing import Any, Generic, Literal, TypeVar, overload
3-
from typing_extensions import ParamSpec
3+
from typing_extensions import ParamSpec, TypeVarTuple, Unpack
44

55
from uwsgi import _RPCCallable
66

77
_T = TypeVar("_T")
88
_T2 = TypeVar("_T2")
9+
_Ts = TypeVarTuple("_Ts")
910
_SR = TypeVar("_SR", bound=Literal[0, -1, -2] | None)
1011
_SignalCallbackT = TypeVar("_SignalCallbackT", bound=Callable[[int], Any])
1112
_RPCCallableT = TypeVar("_RPCCallableT", bound=_RPCCallable)
@@ -166,13 +167,10 @@ class lock(Generic[_P, _T]):
166167
def __init__(self, f: Callable[_P, _T]) -> None: ...
167168
def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _T: ...
168169

169-
# FIXME: Technically this only allows positional arguments, but there is not really
170-
# an adequate way yet to express this, once bound on ParamSpec does something
171-
# we could probably enforce this
172-
class thread(Generic[_P, _T]):
173-
f: Callable[_P, _T]
174-
def __init__(self, f: Callable[_P, _T]) -> None: ...
175-
def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> Callable[_P, _T]: ...
170+
class thread(Generic[Unpack[_Ts], _T]):
171+
f: Callable[[Unpack[_Ts]], _T]
172+
def __init__(self, f: Callable[[Unpack[_Ts]], _T]) -> None: ...
173+
def __call__(self, *args: Unpack[_Ts]) -> Callable[[Unpack[_Ts]], _T]: ...
176174

177175
class harakiri:
178176
s: int

0 commit comments

Comments
 (0)