Python 3.10+typingterm
typing.ParamSpecArgs
generics and parameters
The type of P.args on a ParamSpec — the positional arguments of the captured signature.
Syntax
P.args # тип ParamSpecArgs
You almost never spell this type out by name — a wrapper writes *args: P.args, **kwargs: P.kwargs and ParamSpecArgs falls out automatically. A type checker requires P.args and P.kwargs to appear together on the same function; one without the other is an error.
Examples
from typing import ParamSpec, ParamSpecArgs
P = ParamSpec('P')
print(isinstance(P.args, ParamSpecArgs)) # → True
print(P.args) # → P.args
print(P.args.__origin__ is P) # → True
def wrapper(*args: P.args, **kwargs: P.kwargs) -> None: pass
print(wrapper.__annotations__['args']) # → P.args
See also
Open in the full glossarydocs.python.orgReport an inaccuracy