ParamSpec

E911253

ParamSpec is a Python typing construct that allows you to capture and reuse the parameter types of callable objects, enabling more precise type annotations for higher-order functions.

Try in SPARQL Jump to: Statements Referenced by

Statements (45)

Predicate Object
instanceOf PEP 612 feature
Python typing feature
typing construct
authorOfPEP PEP 612 authors
availableFromPythonVersion 3.10
backportedInModule typing_extensions NERFINISHED
canBeUsedWith Callable
Concatenate
ParamSpecArgs
ParamSpecKwargs
captures keyword parameters of a callable
positional parameters of a callable
category variadic type parameter
definedInModule typing
designGoal allow parameter list variance separate from return type
support precise typing of higher-order functions
enables forwarding of *args and **kwargs types
type-safe decorators
type-safe function wrappers
hasComponent ParamSpec.args
ParamSpec.kwargs
introducedIn PEP 612 NERFINISHED
isVariadic true
limitations cannot be used for non-callable generic parameters
cannot directly express arbitrary argument transformations
namespace typing.ParamSpec
typing_extensions.ParamSpec
parameterKind parameters of a callable
partOf Python type system
relatedTo Callable NERFINISHED
Concatenate
TypeVar
TypeVarTuple NERFINISHED
requires type checkers with PEP 612 support
semantics represents the full parameter specification of a callable
status standard feature in Python 3.10 and later
supports binding to callable parameter lists
syntaxExample P = ParamSpec('P')
typicalUsage def wrapper(*args: P.args, **kwargs: P.kwargs) -> ReturnType:
usedFor capturing parameter types of callables
generic callable parameter lists
precise type annotations for decorators
preserving callable signatures in wrappers
reusing parameter types of callables
typing higher-order functions

Referenced by (1)

Full triples — surface form annotated when it differs from this entity's canonical label.

Type Parameter Syntax relatedTo ParamSpec