File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -31,16 +31,17 @@ def construct_fields(
3131 Currently simply fetches all the attributes from the Pydantic model's __fields__. In
3232 the future we hope to implement field-level overrides that we'll have to merge in.
3333 """
34- fields = {}
35- if only_fields :
36- fields_to_convert = (
37- (k , v ) for k , v in model .__fields__ .items () if k in only_fields
38- )
39- elif exclude_fields :
40- fields_to_convert = (
41- (k , v ) for k , v in model .__fields__ .items () if k not in only_fields
42- )
34+ excluded : typing .Tuple [str , ...] = ()
35+ if exclude_fields :
36+ excluded = exclude_fields
37+ elif only_fields :
38+ excluded = tuple (k for k in model .__fields__ if k not in only_fields )
4339
40+ fields_to_convert = (
41+ (k , v ) for k , v in model .__fields__ .items () if k not in excluded
42+ )
43+
44+ fields = {}
4445 for name , field in fields_to_convert :
4546 converted = convert_pydantic_field (field , registry )
4647 registry .register_orm_field (obj_type , name , field )
You can’t perform that action at this time.
0 commit comments