You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code provided worked in version 0.30.1 but stopped working in versions 0.31.0 and 0.32.0. The issue happens when using a dataclass in a dictionary (i.e., dict[str, Test]).
Traceback (most recent call last):
File "/home/camila/.virtualenvs/gn/lib/python3.10/site-packages/dataclass_wizard/loaders.py", line 592, in fromdict
load = CLASS_TO_LOAD_FUNC[cls]
KeyError: <class '__main__.Config'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/camila/work/test_datawizard.py", line 18, in<module>
test_config = fromdict(Config, config)
File "/home/camila/.virtualenvs/gn/lib/python3.10/site-packages/dataclass_wizard/loaders.py", line 594, in fromdict
load = load_func_for_dataclass(cls)
File "/home/camila/.virtualenvs/gn/lib/python3.10/site-packages/dataclass_wizard/loaders.py", line 650, in load_func_for_dataclass
field_to_parser = dataclass_field_to_load_parser(cls_loader, cls, config)
File "/home/camila/.virtualenvs/gn/lib/python3.10/site-packages/dataclass_wizard/class_helper.py", line 131, in dataclass_field_to_load_parser
return _setup_load_config_for_cls(cls_loader, cls, config, save)
File "/home/camila/.virtualenvs/gn/lib/python3.10/site-packages/dataclass_wizard/class_helper.py", line 211, in _setup_load_config_for_cls
name_to_parser[f.name] = getattr(p := cls_loader.get_parser_for_annotation(
File "/home/camila/.virtualenvs/gn/lib/python3.10/site-packages/dataclass_wizard/loaders.py", line 416, in get_parser_for_annotation
return MappingParser(
File "<string>", line 5, in __init__
File "/home/camila/.virtualenvs/gn/lib/python3.10/site-packages/dataclass_wizard/parsers.py", line 559, in __post_init__
self.val_base_type = val_parser.base_type
AttributeError: 'function' object has no attribute 'base_type'
Thank you for opening this issue and providing a minimal example!
I’ve confirmed it’s a bug and identified the cause. While I initially thought all uses of base_type were confined to UnionParser, it seems I missed one 😅.
I’ll be working on a bugfix patch for this shortly — stay tuned!
Description
The code provided worked in version
0.30.1
but stopped working in versions0.31.0
and0.32.0
. The issue happens when using a dataclass in a dictionary (i.e., dict[str, Test]).What I Did
Code example:
Traceback:
Expected:
The text was updated successfully, but these errors were encountered: