pydantic-core icon indicating copy to clipboard operation
pydantic-core copied to clipboard

support `kwargs` with `from_attributes`

Open samuelcolvin opened this issue 2 years ago • 1 comments

As per https://github.com/samuelcolvin/pydantic/pull/3375 we should support kwargs with from_attributes.

To do this, effectively

https://github.com/samuelcolvin/pydantic-core/blob/fdf42b8b0d0684bc2cac04d34c40fe4b0d33498d/src/input/return_enums.rs#L158

Becomes

PyGetAttr(&'a PyAny, Option<&'a PyDict>),

The dict "wins" over the object if it is some.

Then py_get_attr calls py_get_item first if the option is Some.

samuelcolvin avatar Aug 05 '22 13:08 samuelcolvin

I guess the input validator needs to support a tuple of (object, kwargs) too.

samuelcolvin avatar Aug 05 '22 13:08 samuelcolvin

fixed in #306

samuelcolvin avatar Mar 08 '23 16:03 samuelcolvin