You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched Google & GitHub for similar requests and couldn't find anything
I have read and followed the docs and still think this feature is missing
Description
When using a TypeAdapter on a callable (or using the @validate_call()) decorator, validation from JSON is limited:
frompydanticimportTypeAdapterfrompydantic_coreimportArgsKwargsdeff(a: int, /, *, b: int):
...
ta=TypeAdapter(f)
# From Python, you use `ArgsKwargs`:ta.validate_python(ArgsKwargs((1,), {'b': 1})
# No way to validate from JSONta.validate_json('{"a": 1, "b": 2}') # error
The idea would be to introduce a flag on the arguments_schema(), so that we can validate like this:
Initial Checks
Description
When using a
TypeAdapter
on a callable (or using the@validate_call()
) decorator, validation from JSON is limited:The idea would be to introduce a flag on the
arguments_schema()
, so that we can validate like this:This should work as parameter names should be unique. Note that while something like this could also be done for kwargs:
This won't play well if you have a parameter named
a
.Affected Components
.model_dump()
and.model_dump_json()
model_construct()
, pickling, private attributes, ORM modeThe text was updated successfully, but these errors were encountered: