lidatong / dataclasses-json

Easily serialize Data Classes to and from JSON
MIT License
1.34k stars 150 forks source link

Fix an issue introduced with hetero tuple decode #493

Closed george-zubrienko closed 7 months ago

george-zubrienko commented 8 months ago

Fixes #491

I believe one way to fix this is to simply narrow down use cases for hetero tuples to either types == elements in tuple, or a single type :)

github-actions[bot] commented 8 months ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
dataclasses_json
   cfg.py51492%80, 84–86
   core.py2601893%39–42, 52, 65, 67, 82, 84, 170, 198, 378–385, 389, 395
   mm.py2053085%33–36, 42–45, 53–56, 62–65, 88, 170–171, 176, 180, 184, 189, 193, 197, 205, 211, 216, 225, 230, 235, 244, 253–260
   stringcase.py25388%59, 76, 97
   undefined.py146299%25, 39
   utils.py1313673%12–25, 45–50, 61–65, 75, 100–101, 109–110, 125–133, 163, 182, 207
tests
   entities.py239399%22, 234, 240
   test_annotations.py814248%50–67, 78–102, 106–122
   test_api.py142497%88, 99, 139–140
   test_str_subclass.py22195%9
   test_union.py1311092%97–104, 118–125
TOTAL264715394% 

Tests Skipped Failures Errors Time
305 3 :zzz: 0 :x: 0 :fire: 6.525s :stopwatch:
george-zubrienko commented 8 months ago

@matt035343 so I just leave the if len(type_args) == len(xs): and remove the ==1 branch?

matt035343 commented 8 months ago

@matt035343 so I just leave the if len(type_args) == len(xs): and remove the ==1 branch?

I guess that should do it. Btw, why did you opt for enumerate over zip? Is it performing better?