diff --git a/src/cattrs/_compat.py b/src/cattrs/_compat.py index b691a7e7..85b41a95 100644 --- a/src/cattrs/_compat.py +++ b/src/cattrs/_compat.py @@ -252,7 +252,6 @@ def is_literal(_) -> bool: Set = AbcSet -AbstractSet = AbcSet MutableSet = AbcMutableSet Sequence = AbcSequence MutableSequence = AbcMutableSequence diff --git a/src/cattrs/preconf/cbor2.py b/src/cattrs/preconf/cbor2.py index 13e224ef..6341d898 100644 --- a/src/cattrs/preconf/cbor2.py +++ b/src/cattrs/preconf/cbor2.py @@ -1,12 +1,11 @@ """Preconfigured converters for cbor2.""" +from collections.abc import Set from datetime import date, datetime, timezone from typing import Any, TypeVar, Union from cbor2 import dumps, loads -from cattrs._compat import AbstractSet - from ..converters import BaseConverter, Converter from ..fns import identity from ..literals import is_literal_containing_enums @@ -48,7 +47,7 @@ def configure_converter(converter: BaseConverter): @wrap(Cbor2Converter) def make_converter(*args: Any, **kwargs: Any) -> Cbor2Converter: kwargs["unstruct_collection_overrides"] = { - AbstractSet: list, + Set: list, **kwargs.get("unstruct_collection_overrides", {}), } res = Cbor2Converter(*args, **kwargs) diff --git a/src/cattrs/preconf/json.py b/src/cattrs/preconf/json.py index 2865326f..b6c0ecc2 100644 --- a/src/cattrs/preconf/json.py +++ b/src/cattrs/preconf/json.py @@ -1,11 +1,12 @@ """Preconfigured converters for the stdlib json.""" from base64 import b85decode, b85encode +from collections.abc import Set from datetime import date, datetime from json import dumps, loads from typing import Any, TypeVar, Union -from .._compat import AbstractSet, Counter +from .._compat import Counter from ..converters import BaseConverter, Converter from ..fns import identity from ..literals import is_literal_containing_enums @@ -56,7 +57,7 @@ def configure_converter(converter: BaseConverter): @wrap(JsonConverter) def make_converter(*args: Any, **kwargs: Any) -> JsonConverter: kwargs["unstruct_collection_overrides"] = { - AbstractSet: list, + Set: list, Counter: dict, **kwargs.get("unstruct_collection_overrides", {}), } diff --git a/src/cattrs/preconf/msgpack.py b/src/cattrs/preconf/msgpack.py index 9549dfcb..4e1bddd5 100644 --- a/src/cattrs/preconf/msgpack.py +++ b/src/cattrs/preconf/msgpack.py @@ -1,12 +1,11 @@ """Preconfigured converters for msgpack.""" +from collections.abc import Set from datetime import date, datetime, time, timezone from typing import Any, TypeVar, Union from msgpack import dumps, loads -from cattrs._compat import AbstractSet - from ..converters import BaseConverter, Converter from ..fns import identity from ..literals import is_literal_containing_enums @@ -55,7 +54,7 @@ def configure_converter(converter: BaseConverter): @wrap(MsgpackConverter) def make_converter(*args: Any, **kwargs: Any) -> MsgpackConverter: kwargs["unstruct_collection_overrides"] = { - AbstractSet: list, + Set: list, **kwargs.get("unstruct_collection_overrides", {}), } res = MsgpackConverter(*args, **kwargs) diff --git a/src/cattrs/preconf/orjson.py b/src/cattrs/preconf/orjson.py index ec78bdea..6e0b6b80 100644 --- a/src/cattrs/preconf/orjson.py +++ b/src/cattrs/preconf/orjson.py @@ -1,6 +1,7 @@ """Preconfigured converters for orjson.""" from base64 import b85decode, b85encode +from collections.abc import Set from datetime import date, datetime from enum import Enum from functools import partial @@ -8,8 +9,8 @@ from orjson import dumps, loads -from .._compat import AbstractSet, is_mapping, is_subclass -from ..cols import is_namedtuple, namedtuple_unstructure_factory +from .._compat import is_subclass +from ..cols import is_mapping, is_namedtuple, namedtuple_unstructure_factory from ..converters import BaseConverter, Converter from ..fns import identity from ..literals import is_literal_containing_enums @@ -96,7 +97,7 @@ def key_handler(v): @wrap(OrjsonConverter) def make_converter(*args: Any, **kwargs: Any) -> OrjsonConverter: kwargs["unstruct_collection_overrides"] = { - AbstractSet: list, + Set: list, **kwargs.get("unstruct_collection_overrides", {}), } res = OrjsonConverter(*args, **kwargs) diff --git a/src/cattrs/preconf/tomlkit.py b/src/cattrs/preconf/tomlkit.py index 1d321e31..ace6c360 100644 --- a/src/cattrs/preconf/tomlkit.py +++ b/src/cattrs/preconf/tomlkit.py @@ -1,6 +1,7 @@ """Preconfigured converters for tomlkit.""" from base64 import b85decode, b85encode +from collections.abc import Set from datetime import date, datetime from enum import Enum from operator import attrgetter @@ -9,7 +10,7 @@ from tomlkit import dumps, loads from tomlkit.items import Float, Integer, String -from .._compat import AbstractSet, is_mapping, is_subclass +from .._compat import is_mapping, is_subclass from ..converters import BaseConverter, Converter from ..strategies import configure_union_passthrough from . import validate_datetime, wrap @@ -76,7 +77,7 @@ def key_handler(k: bytes): @wrap(TomlkitConverter) def make_converter(*args: Any, **kwargs: Any) -> TomlkitConverter: kwargs["unstruct_collection_overrides"] = { - AbstractSet: list, + Set: list, tuple: list, **kwargs.get("unstruct_collection_overrides", {}), } diff --git a/src/cattrs/preconf/ujson.py b/src/cattrs/preconf/ujson.py index 0c7fec4e..bc9b1084 100644 --- a/src/cattrs/preconf/ujson.py +++ b/src/cattrs/preconf/ujson.py @@ -1,12 +1,12 @@ """Preconfigured converters for ujson.""" from base64 import b85decode, b85encode +from collections.abc import Set from datetime import date, datetime from typing import Any, AnyStr, TypeVar, Union from ujson import dumps, loads -from .._compat import AbstractSet from ..converters import BaseConverter, Converter from ..fns import identity from ..literals import is_literal_containing_enums @@ -55,7 +55,7 @@ def configure_converter(converter: BaseConverter): @wrap(UjsonConverter) def make_converter(*args: Any, **kwargs: Any) -> UjsonConverter: kwargs["unstruct_collection_overrides"] = { - AbstractSet: list, + Set: list, **kwargs.get("unstruct_collection_overrides", {}), } res = UjsonConverter(*args, **kwargs)