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>(
12
12
) -> PyResult < Option < T > > {
13
13
let py = schema. py ( ) ;
14
14
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" ) ) ?) {
21
20
return Ok ( None ) ;
22
21
}
23
22
You can’t perform that action at this time.
0 commit comments