File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -163,14 +163,16 @@ def _get_annotated_fields(cls: type) -> Sequence[_Field]:
163163 from inspect import get_annotations
164164
165165 result = []
166- cls_ann : Mapping [str , type ] | None = None
166+ field_name_to_type : Mapping [str , type ] | None = None
167167 for field in fields (cls ):
168168 field_type_or_str = field .type
169169 if isinstance (field_type_or_str , str ):
170- if cls_ann is None :
171- cls_ann = get_annotations (cls , eval_str = True )
170+ if field_name_to_type is None :
171+ field_name_to_type = {}
172+ for subcls in cls .__mro__ [::- 1 ]:
173+ field_name_to_type .update (get_annotations (subcls , eval_str = True ))
172174
173- field_type = cls_ann [field .name ]
175+ field_type = field_name_to_type [field .name ]
174176 else :
175177 field_type = field_type_or_str
176178
You can’t perform that action at this time.
0 commit comments