We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0522748 commit e0ef506Copy full SHA for e0ef506
1 file changed
arraycontext/container/dataclass.py
@@ -163,14 +163,16 @@ def _get_annotated_fields(cls: type) -> Sequence[_Field]:
163
from inspect import get_annotations
164
165
result = []
166
- cls_ann: Mapping[str, type] | None = None
+ field_name_to_type: Mapping[str, type] | None = None
167
for field in fields(cls):
168
field_type_or_str = field.type
169
if isinstance(field_type_or_str, str):
170
- if cls_ann is None:
171
- cls_ann = get_annotations(cls, eval_str=True)
+ if field_name_to_type is None:
+ field_name_to_type = {}
172
+ for subcls in cls.__mro__[::-1]:
173
+ field_name_to_type.update(get_annotations(subcls, eval_str=True))
174
- field_type = cls_ann[field.name]
175
+ field_type = field_name_to_type[field.name]
176
else:
177
field_type = field_type_or_str
178
0 commit comments