Skip to content

Commit

Permalink
feat: fix compatibility issue with python3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
PJCampi committed May 23, 2024
1 parent e656b29 commit 7e19a59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dataclasses_json/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

confs = ['encoder', 'decoder', 'mm_field', 'letter_case', 'exclude']
FieldOverride = namedtuple('FieldOverride', confs) # type: ignore
collections_abc_mapping = MappingProxyType({
collections_abc_type_to_implementation_type = MappingProxyType({
ABCCollection: tuple,
ABCMapping: dict,
MutableMapping: dict,
Expand Down Expand Up @@ -322,7 +322,7 @@ def _decode_generic(type_, value, infer_missing):
materialize_type = type_

# map abstract collection to concrete implementation
materialize_type = collections_abc_mapping.get(materialize_type, materialize_type)
materialize_type = collections_abc_type_to_implementation_type.get(materialize_type, materialize_type)

res = materialize_type(xs)
elif _is_generic_dataclass(type_):
Expand Down
3 changes: 2 additions & 1 deletion tests/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
from uuid import UUID
if sys.version_info >= (3, 9):
from collections import Counter
from collections.abc import Mapping, MutableMapping, MutableSequence, MutableSet, Sequence, Set as ABCSet
else:
from typing import Counter
from typing import Counter, Mapping, MutableMapping, MutableSequence, MutableSet, Sequence, Set as ABCSet

from marshmallow import fields

Expand Down

0 comments on commit 7e19a59

Please sign in to comment.