lidatong / dataclasses-json

Easily serialize Data Classes to and from JSON
MIT License
1.36k stars 153 forks source link

Support for Counter objects #471

Closed matt035343 closed 1 year ago

matt035343 commented 1 year ago

Based on https://github.com/lidatong/dataclasses-json/pull/363, I have resolved the conflicts and fixed a bug I found when updating the rest of the code base.

@n1chre please have a look.

github-actions[bot] commented 1 year ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
dataclasses_json
   cfg.py51492%80, 84–86
   core.py2371096%38–41, 51, 64, 66, 81, 83, 169, 197
   mm.py2023085%33–36, 42–45, 53–56, 62–65, 88, 161–162, 167, 171, 175, 180, 184, 188, 196, 202, 207, 216, 221, 226, 235, 244–251
   stringcase.py25388%59, 76, 97
   undefined.py143299%24, 38
   utils.py1313673%12–25, 45–50, 61–65, 75, 100–101, 109–110, 125–133, 163, 182, 207
tests
   entities.py234399%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.py981090%87–94, 108–115
TOTAL250314594% 

Tests Skipped Failures Errors Time
294 3 :zzz: 0 :x: 0 :fire: 5.858s :stopwatch:
matt035343 commented 1 year ago

@george-zubrienko Since it is only the typing alias that is deprecated I can use collections.Counter instead. I still think support for Counter is relevant even though it is just a wrapper.

george-zubrienko commented 1 year ago

@george-zubrienko Since it is only the typing alias that is deprecated I can use collections.Counter instead. I still think support for Counter is relevant even though it is just a wrapper.

Yeah I do not deny this is needed, I'm just curious if we can fallback to code that handles dict instead of writing logic specific to Counter type, given this might break due to import being removed in future python versions?

matt035343 commented 1 year ago

I will merge this by the end of this week unless @n1chre raises any concerns