dataclasses-json
dataclasses-json copied to clipboard
TypeError: Type Dict cannot be instantiated; use dict() instead
I'm getting this error, is the package not able to work with the new generic python Typing?
@George3d6, please, attach more information:
- Python version
- OS
- Code fragment invoking the error
- Stack trace
I encountered a similar exception with lists which might be the same underlying bug: https://github.com/lidatong/dataclasses-json/issues/310
Have just encountered this in my code. It's probably these lines in core.py (around line 267) masking an issue with something inside your dict:
try:
res = _get_type_cons(type_)(xs)
except (TypeError, AttributeError):
res = type_(xs)
As a work-around I replaced them with these:
try:
tp = _get_type_cons(type_)
except (TypeError, AttributeError):
tp = type_
res = tp(xs)
which exposed the issue in my dataclass inside my dict.
Closing due to lack of details. Maybe related to https://github.com/lidatong/dataclasses-json/issues/232. Please reopen if the issue persists or if you can provide more details.