arguments_parameter
Returns a schema that matches an argument parameter, e.g.:
from pydantic_core import SchemaValidator, core_schema
param = core_schema.arguments_parameter(
name='a', schema=core_schema.str_schema(), mode='positional_only'
)
schema = core_schema.arguments_schema([param])
v = SchemaValidator(schema)
assert v.validate_python(('hello',)) == (('hello',), {})
Args: name: The name to use for the argument parameter schema: The schema to use for the argument parameter mode: The mode to use for the argument parameter alias: The alias to use for the argument parameter
def arguments_parameter(
name: str,
schema: CoreSchema,
mode: Literal['positional_only', 'positional_or_keyword', 'keyword_only'] | None = None,
alias: str | list[str | int] | list[list[str | int]] | None = None
) - > ArgumentsParameter
Returns a schema that matches an argument parameter, e.g.:
from pydantic_core import SchemaValidator, core_schema
param = core_schema.arguments_parameter(
name='a', schema=core_schema.str_schema(), mode='positional_only'
)
schema = core_schema.arguments_schema([param])
v = SchemaValidator(schema)
assert v.validate_python(('hello',)) == (('hello',), {})
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The name to use for the argument parameter |
| schema | CoreSchema | The schema to use for the argument parameter |
| mode | `Literal['positional_only', 'positional_or_keyword', 'keyword_only'] | None` = None |
| alias | `str | list[str |
Returns
| Type | Description |
|---|---|
ArgumentsParameter | A dictionary representing the configuration for a single argument within an arguments schema |