@@ -3498,6 +3498,112 @@ def arguments_schema(
34983498 )
34993499
35003500
3501+ class ArgumentsV2Parameter (TypedDict , total = False ):
3502+ name : Required [str ]
3503+ schema : Required [CoreSchema ]
3504+ mode : Literal [
3505+ 'positional_only' ,
3506+ 'positional_or_keyword' ,
3507+ 'keyword_only' ,
3508+ 'var_args' ,
3509+ 'var_kwargs_uniform' ,
3510+ 'var_kwargs_unpacked_typed_dict' ,
3511+ ] # default positional_or_keyword
3512+ alias : Union [str , list [Union [str , int ]], list [list [Union [str , int ]]]]
3513+
3514+
3515+ def arguments_v2_parameter (
3516+ name : str ,
3517+ schema : CoreSchema ,
3518+ * ,
3519+ mode : Literal [
3520+ 'positional_only' ,
3521+ 'positional_or_keyword' ,
3522+ 'keyword_only' ,
3523+ 'var_args' ,
3524+ 'var_kwargs_uniform' ,
3525+ 'var_kwargs_unpacked_typed_dict' ,
3526+ ]
3527+ | None = None ,
3528+ alias : str | list [str | int ] | list [list [str | int ]] | None = None ,
3529+ ) -> ArgumentsV2Parameter :
3530+ """
3531+ Returns a schema that matches an argument parameter, e.g.:
3532+
3533+ ```py
3534+ from pydantic_core import SchemaValidator, core_schema
3535+
3536+ param = core_schema.arguments_v2_parameter(
3537+ name='a', schema=core_schema.str_schema(), mode='positional_only'
3538+ )
3539+ schema = core_schema.arguments_v2_schema([param])
3540+ v = SchemaValidator(schema)
3541+ assert v.validate_python({'a': 'hello'}) == (('hello',), {})
3542+ ```
3543+
3544+ Args:
3545+ name: The name to use for the argument parameter
3546+ schema: The schema to use for the argument parameter
3547+ mode: The mode to use for the argument parameter
3548+ alias: The alias to use for the argument parameter
3549+ """
3550+ return _dict_not_none (name = name , schema = schema , mode = mode , alias = alias )
3551+
3552+
3553+ class ArgumentsV2Schema (TypedDict , total = False ):
3554+ type : Required [Literal ['arguments-v2' ]]
3555+ arguments_schema : Required [list [ArgumentsV2Parameter ]]
3556+ populate_by_name : bool
3557+ var_args_schema : CoreSchema
3558+ var_kwargs_mode : VarKwargsMode
3559+ var_kwargs_schema : CoreSchema
3560+ ref : str
3561+ metadata : dict [str , Any ]
3562+ serialization : SerSchema
3563+
3564+
3565+ def arguments_v2_schema (
3566+ arguments : list [ArgumentsV2Parameter ],
3567+ * ,
3568+ populate_by_name : bool | None = None ,
3569+ ref : str | None = None ,
3570+ metadata : dict [str , Any ] | None = None ,
3571+ serialization : SerSchema | None = None ,
3572+ ) -> ArgumentsV2Schema :
3573+ """
3574+ Returns a schema that matches an arguments schema, e.g.:
3575+
3576+ ```py
3577+ from pydantic_core import SchemaValidator, core_schema
3578+
3579+ param_a = core_schema.arguments_v2_parameter(
3580+ name='a', schema=core_schema.str_schema(), mode='positional_only'
3581+ )
3582+ param_b = core_schema.arguments_v2_parameter(
3583+ name='kwargs', schema=core_schema.bool_schema(), mode='var_kwargs_uniform'
3584+ )
3585+ schema = core_schema.arguments_v2_schema([param_a, param_b])
3586+ v = SchemaValidator(schema)
3587+ assert v.validate_python({'a': 'hello', 'kwargs': {'extra': True}}) == (('hello',), {'extra': True})
3588+ ```
3589+
3590+ Args:
3591+ arguments: The arguments to use for the arguments schema
3592+ populate_by_name: Whether to populate by name
3593+ ref: optional unique identifier of the schema, used to reference the schema in other places
3594+ metadata: Any other information you want to include with the schema, not used by pydantic-core
3595+ serialization: Custom serialization schema
3596+ """
3597+ return _dict_not_none (
3598+ type = 'arguments-v2' ,
3599+ arguments_schema = arguments ,
3600+ populate_by_name = populate_by_name ,
3601+ ref = ref ,
3602+ metadata = metadata ,
3603+ serialization = serialization ,
3604+ )
3605+
3606+
35013607class CallSchema (TypedDict , total = False ):
35023608 type : Required [Literal ['call' ]]
35033609 arguments_schema : Required [CoreSchema ]
0 commit comments