Skip to content
You're viewing docs for v2.11. See the latest version →

Experimental

Experimental pipeline API functionality. Be careful with this API, it’s subject to change.

Experimental module exposing a function to generate a core schema that validates callable arguments.

generate_arguments_schema

def generate_arguments_schema(
    func: Callable[..., Any],
    schema_type: Literal['arguments', 'arguments-v3'] = 'arguments-v3',
    parameters_callback: Callable[[int, str, Any], Literal['skip'] | None] | None = None,
    config: ConfigDict | None = None,
) -> CoreSchema

Generate the schema for the arguments of a function.

Returns

CoreSchema — The generated schema.

Parameters

func : Callable[..., Any]

The function to generate the schema for.

schema_type : Literal['arguments', 'arguments-v3'] Default: 'arguments-v3'

The type of schema to generate.

parameters_callback : Callable[[int, str, Any], Literal['skip'] | None] | None Default: None

A callable that will be invoked for each parameter. The callback should take three required arguments: the index, the name and the type annotation (or Parameter.empty if not annotated) of the parameter. The callback can optionally return 'skip', so that the parameter gets excluded from the resulting schema.

config : ConfigDict | None Default: None

The configuration to use.