Skip to main content

call_schema

Returns a schema that matches an arguments schema, then calls a function, e.g.:

```py
from pydantic_core import SchemaValidator, core_schema

param_a = core_schema.arguments_parameter(
name='a', schema=core_schema.str_schema(), mode='positional_only'
)
param_b = core_schema.arguments_parameter(
name='b', schema=core_schema.bool_schema(), mode='positional_only'
)
args_schema = core_schema.arguments_schema([param_a, param_b])

schema = core_schema.call_schema(
arguments=args_schema,
function=lambda a, b: a + str(not b),
return_schema=core_schema.str_schema(),
)
v = SchemaValidator(schema)
assert v.validate_python((('hello', True))) == 'helloFalse'
```
def call_schema(
arguments: CoreSchema,
function: Callable[..., Any],
function_name: str | None = null,
return_schema: CoreSchema | None = null,
ref: str | None = null,
metadata: dict[str, Any] | None = null,
serialization: SerSchema | None = null
) - > CallSchema

Returns a schema that matches an arguments schema, then calls a function.

Parameters

NameTypeDescription
argumentsCoreSchemaThe schema used to validate and parse the input arguments before the function call.
functionCallable[..., Any]The callable object to be executed using the validated arguments.
function_name`strNone` = null
return_schema`CoreSchemaNone` = null
ref`strNone` = null
metadata`dict[str, Any]None` = null
serialization`SerSchemaNone` = null

Returns

TypeDescription
CallSchemaA schema definition that validates input arguments and executes the specified callable with the validated data.