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(
31
31
Currently simply fetches all the attributes from the Pydantic model's __fields__. In
32
32
the future we hope to implement field-level overrides that we'll have to merge in.
33
33
"""
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 )
43
39
40
+ fields_to_convert = (
41
+ (k , v ) for k , v in model .__fields__ .items () if k not in excluded
42
+ )
43
+
44
+ fields = {}
44
45
for name , field in fields_to_convert :
45
46
converted = convert_pydantic_field (field , registry )
46
47
registry .register_orm_field (obj_type , name , field )
You can’t perform that action at this time.
0 commit comments