dataclasses-json icon indicating copy to clipboard operation
dataclasses-json copied to clipboard

TypeError: Type Dict cannot be instantiated; use dict() instead

Open George3d6 opened this issue 2 years ago • 3 comments

I'm getting this error, is the package not able to work with the new generic python Typing?

George3d6 avatar Jul 08 '21 19:07 George3d6

@George3d6, please, attach more information:

  • Python version
  • OS
  • Code fragment invoking the error
  • Stack trace

USSX-Hares avatar Jul 12 '21 10:07 USSX-Hares

I encountered a similar exception with lists which might be the same underlying bug: https://github.com/lidatong/dataclasses-json/issues/310

tindzk avatar Aug 22 '21 13:08 tindzk

Check this

amjed-ali-k avatar Jul 24 '22 10:07 amjed-ali-k

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.

JonathanRoach avatar Mar 29 '23 11:03 JonathanRoach

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.

matt035343 avatar Jul 22 '23 09:07 matt035343