Python 3.10+typingterm
typing.ParamSpecKwargs
generics and parameters
The type of P.kwargs on a ParamSpec — the keyword arguments of the captured signature.
Syntax
P.kwargs # тип ParamSpecKwargs
As with P.args, you don't name this type directly — a wrapper just uses **kwargs: P.kwargs. Both P.args and P.kwargs must appear together on the same function; a type checker treats using one alone as an error.
Examples
from typing import ParamSpec, ParamSpecKwargs
P = ParamSpec('P')
print(isinstance(P.kwargs, ParamSpecKwargs)) # → True
print(P.kwargs) # → P.kwargs
print(P.kwargs.__origin__ is P) # → True
def wrapper(*args: P.args, **kwargs: P.kwargs) -> None: pass
print(isinstance(P.args, ParamSpecKwargs)) # → False
See also
Open in the full glossarydocs.python.orgReport an inaccuracy