Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uWSGI: Use a TypeVarTuple in uwsgidecorators.thread #11128

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions stubs/uWSGI/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@
uwsgidecorators.erlang
# This should really only be internal API, so we don't export it
uwsgidecorators.harakiri.real_call

# Error: is inconsistent
# ======================
# This is a limitation of ParamSpec, we can't specify that the
# the ParamSpec does have no keyword arguments, but we need the
# ParamSpec to properly annotate this decorator
uwsgidecorators.thread.__call__
14 changes: 6 additions & 8 deletions stubs/uWSGI/uwsgidecorators.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from collections.abc import Callable
from typing import Any, Generic, Literal, TypeVar, overload
from typing_extensions import ParamSpec
from typing_extensions import ParamSpec, TypeVarTuple, Unpack

from uwsgi import _RPCCallable

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

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

class harakiri:
s: int
Expand Down
Loading