File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -12,11 +12,12 @@ 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" ) ) ?
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 !matches ! ( type_, "model" | "dataclass" )
20+ || ( type_ == "dataclass" && schema. contains ( intern ! ( py, "generic_origin" ) ) ?)
2021 {
2122 return Ok ( None ) ;
2223 }
You can’t perform that action at this time.
0 commit comments