File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,11 @@ pub fn get_prebuilt<T>(
1212) -> PyResult < Option < T > > {
1313 let py = schema. py ( ) ;
1414
15- // we can only use prebuilt validators / serializers from models, typed dicts, and dataclasses
16- // however, we don't want to use a prebuilt structure from dataclasses if we have a generic_origin
17- // because the validator / serializer is cached on the unparametrized dataclass
18- if !matches ! ( type_, "model" | "typed-dict" )
19- || matches ! ( type_, "dataclass" ) && schema. contains ( intern ! ( py, "generic_origin" ) ) ?
20- {
15+ // we can only use prebuilt validators/serializers from models and Pydantic dataclasses.
16+ // However, we don't want to use a prebuilt structure from dataclasses if we have a `generic_origin`
17+ // as this means the dataclass was parametrized (so a generic alias instance), and `cls` in the
18+ // core schema is still the (unparametrized) class, meaning we would fetch the wrong validator/serializer.
19+ if !( type_ == "model" ) || ( type_ == "dataclass" && schema. contains ( intern ! ( py, "generic_origin" ) ) ?) {
2120 return Ok ( None ) ;
2221 }
2322
You can’t perform that action at this time.
0 commit comments