From 088a908b73cf6f7d9592ab35601c51455740f69c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Apr 2022 00:32:20 +0000 Subject: [PATCH 1/4] Bump mashumaro from 2.9 to 3.0.1 in /core --- core/dbt/contracts/graph/manifest.py | 2 +- core/setup.py | 2 +- third-party-stubs/mashumaro/__init__.pyi | 7 +- third-party-stubs/mashumaro/config.pyi | 25 +++- .../mashumaro/{meta => core}/__init__.pyi | 0 third-party-stubs/mashumaro/core/const.pyi | 13 ++ third-party-stubs/mashumaro/core/helpers.pyi | 3 + .../{serializer => core/meta}/__init__.pyi | 0 .../mashumaro/core/meta/builder.pyi | 115 ++++++++++++++++++ .../mashumaro/core/meta/helpers.pyi | 37 ++++++ .../mashumaro/{ => core}/meta/patch.pyi | 0 third-party-stubs/mashumaro/dialect.pyi | 7 ++ .../mashumaro/dialects/__init__.pyi | 0 .../mashumaro/dialects/msgpack.pyi | 5 + third-party-stubs/mashumaro/exceptions.pyi | 31 ++++- third-party-stubs/mashumaro/helper.pyi | 24 ++++ third-party-stubs/mashumaro/meta/helpers.pyi | 11 -- third-party-stubs/mashumaro/meta/macros.pyi | 6 - .../mashumaro/mixins/__init__.pyi | 0 third-party-stubs/mashumaro/mixins/dict.pyi | 15 +++ third-party-stubs/mashumaro/mixins/json.pyi | 19 +++ .../mashumaro/mixins/msgpack.pyi | 24 ++++ third-party-stubs/mashumaro/mixins/yaml.pyi | 25 ++++ .../mashumaro/serializer/base/__init__.pyi | 1 - .../mashumaro/serializer/base/dict.pyi | 22 ---- .../mashumaro/serializer/base/helpers.pyi | 3 - .../serializer/base/metaprogramming.pyi | 45 ------- .../mashumaro/serializer/json.pyi | 21 ---- .../mashumaro/serializer/msgpack.pyi | 21 ---- .../mashumaro/serializer/yaml.pyi | 21 ---- third-party-stubs/mashumaro/types.pyi | 23 ++-- 31 files changed, 353 insertions(+), 175 deletions(-) rename third-party-stubs/mashumaro/{meta => core}/__init__.pyi (100%) create mode 100644 third-party-stubs/mashumaro/core/const.pyi create mode 100644 third-party-stubs/mashumaro/core/helpers.pyi rename third-party-stubs/mashumaro/{serializer => core/meta}/__init__.pyi (100%) create mode 100644 third-party-stubs/mashumaro/core/meta/builder.pyi create mode 100644 third-party-stubs/mashumaro/core/meta/helpers.pyi rename third-party-stubs/mashumaro/{ => core}/meta/patch.pyi (100%) create mode 100644 third-party-stubs/mashumaro/dialect.pyi create mode 100644 third-party-stubs/mashumaro/dialects/__init__.pyi create mode 100644 third-party-stubs/mashumaro/dialects/msgpack.pyi create mode 100644 third-party-stubs/mashumaro/helper.pyi delete mode 100644 third-party-stubs/mashumaro/meta/helpers.pyi delete mode 100644 third-party-stubs/mashumaro/meta/macros.pyi create mode 100644 third-party-stubs/mashumaro/mixins/__init__.pyi create mode 100644 third-party-stubs/mashumaro/mixins/dict.pyi create mode 100644 third-party-stubs/mashumaro/mixins/json.pyi create mode 100644 third-party-stubs/mashumaro/mixins/msgpack.pyi create mode 100644 third-party-stubs/mashumaro/mixins/yaml.pyi delete mode 100644 third-party-stubs/mashumaro/serializer/base/__init__.pyi delete mode 100644 third-party-stubs/mashumaro/serializer/base/dict.pyi delete mode 100644 third-party-stubs/mashumaro/serializer/base/helpers.pyi delete mode 100644 third-party-stubs/mashumaro/serializer/base/metaprogramming.pyi delete mode 100644 third-party-stubs/mashumaro/serializer/json.pyi delete mode 100644 third-party-stubs/mashumaro/serializer/msgpack.pyi delete mode 100644 third-party-stubs/mashumaro/serializer/yaml.pyi diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index 1d34a209307..20d82cfafaf 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -1,7 +1,7 @@ import enum from dataclasses import dataclass, field from itertools import chain, islice -from mashumaro import DataClassMessagePackMixin +from mashumaro.mixins.msgpack import DataClassMessagePackMixin from multiprocessing.synchronize import Lock from typing import ( Dict, diff --git a/core/setup.py b/core/setup.py index 6d67a65aed7..1bb52f87e63 100644 --- a/core/setup.py +++ b/core/setup.py @@ -56,7 +56,7 @@ "hologram>=0.0.14,<=0.0.15", "isodate>=0.6,<0.7", "logbook>=1.5,<1.6", - "mashumaro==2.9", + "mashumaro[msgpack]==3.0.1", "minimal-snowplow-tracker==0.0.2", "networkx>=2.3,<2.8.1;python_version<'3.8'", "networkx>=2.3,<3;python_version>='3.8'", diff --git a/third-party-stubs/mashumaro/__init__.pyi b/third-party-stubs/mashumaro/__init__.pyi index 662aa36260e..7a63477629b 100644 --- a/third-party-stubs/mashumaro/__init__.pyi +++ b/third-party-stubs/mashumaro/__init__.pyi @@ -1,5 +1,4 @@ from mashumaro.exceptions import MissingField as MissingField -from mashumaro.serializer.base.dict import DataClassDictMixin as DataClassDictMixin -from mashumaro.serializer.json import DataClassJSONMixin as DataClassJSONMixin -from mashumaro.serializer.msgpack import DataClassMessagePackMixin as DataClassMessagePackMixin -from mashumaro.serializer.yaml import DataClassYAMLMixin as DataClassYAMLMixin +from mashumaro.helper import field_options as field_options, pass_through as pass_through +from mashumaro.mixins.dict import DataClassDictMixin as DataClassDictMixin +from mashumaro.mixins.msgpack import DataClassMessagePackMixin as DataClassMessagePackMixin diff --git a/third-party-stubs/mashumaro/config.pyi b/third-party-stubs/mashumaro/config.pyi index 04a5cb1070b..8263ceb46fe 100644 --- a/third-party-stubs/mashumaro/config.pyi +++ b/third-party-stubs/mashumaro/config.pyi @@ -1,10 +1,31 @@ -from mashumaro.types import SerializationStrategy as SerializationStrategy -from typing import Any, Callable, Dict, List, Union +from mashumaro.dialect import Dialect +from mashumaro.types import SerializationStrategy +from typing import Any, Callable, Dict, List, Optional, Type, Union +from mashumaro.core.const import PEP_586_COMPATIBLE +if PEP_586_COMPATIBLE: + from typing import Literal # type: ignore +else: + from typing_extensions import Literal # type: ignore + +TO_DICT_ADD_BY_ALIAS_FLAG: str TO_DICT_ADD_OMIT_NONE_FLAG: str +ADD_DIALECT_SUPPORT: str + +CodeGenerationOption = Literal[ + "TO_DICT_ADD_BY_ALIAS_FLAG", + "TO_DICT_ADD_OMIT_NONE_FLAG", + "ADD_DIALECT_SUPPORT", +] + SerializationStrategyValueType = Union[SerializationStrategy, Dict[str, Union[str, Callable]]] class BaseConfig: debug: bool = ... code_generation_options: List[str] = ... serialization_strategy: Dict[Any, SerializationStrategyValueType] = ... + aliases: Dict[str, str] = ... + serialize_by_alias: bool = ... + namedtuple_as_dict: bool = ... + allow_postponed_evaluation: bool = ... + dialect: Optional[Type[Dialect]] = ... diff --git a/third-party-stubs/mashumaro/meta/__init__.pyi b/third-party-stubs/mashumaro/core/__init__.pyi similarity index 100% rename from third-party-stubs/mashumaro/meta/__init__.pyi rename to third-party-stubs/mashumaro/core/__init__.pyi diff --git a/third-party-stubs/mashumaro/core/const.pyi b/third-party-stubs/mashumaro/core/const.pyi new file mode 100644 index 00000000000..c76e457dfe1 --- /dev/null +++ b/third-party-stubs/mashumaro/core/const.pyi @@ -0,0 +1,13 @@ +from typing import Any + +PY_36: Any +PY_37: Any +PY_38: Any +PY_39: Any +PY_310: Any +PY_37_MIN: Any +PY_38_MIN: Any +PY_39_MIN: Any +PY_310_MIN = PY_310 +PEP_585_COMPATIBLE = PY_39_MIN +PEP_586_COMPATIBLE = PY_38_MIN diff --git a/third-party-stubs/mashumaro/core/helpers.pyi b/third-party-stubs/mashumaro/core/helpers.pyi new file mode 100644 index 00000000000..326e5cccf4c --- /dev/null +++ b/third-party-stubs/mashumaro/core/helpers.pyi @@ -0,0 +1,3 @@ +import datetime + +def parse_timezone(s: str) -> datetime.timezone: ... diff --git a/third-party-stubs/mashumaro/serializer/__init__.pyi b/third-party-stubs/mashumaro/core/meta/__init__.pyi similarity index 100% rename from third-party-stubs/mashumaro/serializer/__init__.pyi rename to third-party-stubs/mashumaro/core/meta/__init__.pyi diff --git a/third-party-stubs/mashumaro/core/meta/builder.pyi b/third-party-stubs/mashumaro/core/meta/builder.pyi new file mode 100644 index 00000000000..99bc7f98174 --- /dev/null +++ b/third-party-stubs/mashumaro/core/meta/builder.pyi @@ -0,0 +1,115 @@ +from mashumaro.core.helpers import * +import types +import typing +from base64 import decodebytes as decodebytes, encodebytes as encodebytes +from dataclasses import Field +from mashumaro.config import ( + ADD_DIALECT_SUPPORT as ADD_DIALECT_SUPPORT, + BaseConfig as BaseConfig, + TO_DICT_ADD_BY_ALIAS_FLAG as TO_DICT_ADD_BY_ALIAS_FLAG, + TO_DICT_ADD_OMIT_NONE_FLAG as TO_DICT_ADD_OMIT_NONE_FLAG, +) +from mashumaro.core.const import PY_39_MIN as PY_39_MIN +from mashumaro.core.meta.helpers import ( + get_args as get_args, + get_class_that_defines_field as get_class_that_defines_field, + get_class_that_defines_method as get_class_that_defines_method, + get_literal_values as get_literal_values, + get_name_error_name as get_name_error_name, + get_type_origin as get_type_origin, + is_class_var as is_class_var, + is_dataclass_dict_mixin as is_dataclass_dict_mixin, + is_dataclass_dict_mixin_subclass as is_dataclass_dict_mixin_subclass, + is_dialect_subclass as is_dialect_subclass, + is_generic as is_generic, + is_init_var as is_init_var, + is_literal as is_literal, + is_named_tuple as is_named_tuple, + is_new_type as is_new_type, + is_optional as is_optional, + is_special_typing_primitive as is_special_typing_primitive, + is_type_var as is_type_var, + is_type_var_any as is_type_var_any, + is_typed_dict as is_typed_dict, + is_union as is_union, + not_none_type_arg as not_none_type_arg, + resolve_type_vars as resolve_type_vars, + type_name as type_name, +) +from mashumaro.core.meta.patch import patch_fromisoformat as patch_fromisoformat +from mashumaro.dialect import Dialect as Dialect +from mashumaro.exceptions import ( + BadDialect as BadDialect, + BadHookSignature as BadHookSignature, + InvalidFieldValue as InvalidFieldValue, + MissingField as MissingField, + ThirdPartyModuleNotFoundError as ThirdPartyModuleNotFoundError, + UnresolvedTypeReferenceError as UnresolvedTypeReferenceError, + UnserializableDataError as UnserializableDataError, + UnserializableField as UnserializableField, + UnsupportedDeserializationEngine as UnsupportedDeserializationEngine, + UnsupportedSerializationEngine as UnsupportedSerializationEngine, +) +from mashumaro.helper import pass_through as pass_through +from mashumaro.types import ( + GenericSerializableType as GenericSerializableType, + SerializableType as SerializableType, + SerializationStrategy as SerializationStrategy, +) +from typing import Any + +NoneType: Any +__PRE_SERIALIZE__: str +__PRE_DESERIALIZE__: str +__POST_SERIALIZE__: str +__POST_DESERIALIZE__: str + +class CodeLines: + def __init__(self) -> None: ... + def append(self, line: str) -> None: ... + def indent(self) -> typing.Generator[None, None, None]: ... + def as_text(self) -> str: ... + def reset(self) -> None: ... + +class CodeBuilder: + cls: Any = ... + lines: Any = ... + globals: Any = ... + type_vars: Any = ... + field_classes: Any = ... + initial_arg_types: Any = ... + dialect: Any = ... + allow_postponed_evaluation: Any = ... + def __init__( + self, + cls: Any, + arg_types: typing.Tuple = ..., + dialect: typing.Optional[typing.Type[Dialect]] = ..., + first_method: str = ..., + allow_postponed_evaluation: bool = ..., + ) -> None: ... + def reset(self) -> None: ... + @property + def namespace(self) -> typing.Dict[typing.Any, typing.Any]: ... + @property + def annotations(self) -> typing.Dict[str, typing.Any]: ... + @property + def field_types(self) -> typing.Dict[str, typing.Any]: ... + @property + def dataclass_fields(self) -> typing.Dict[str, Field]: ... + @property + def metadatas(self) -> typing.Dict[str, typing.Mapping[str, typing.Any]]: ... + def get_field_default(self, name: str) -> typing.Any: ... + def ensure_module_imported(self, module: types.ModuleType) -> None: ... + def add_line(self, line: str) -> None: ... + def indent(self) -> typing.Generator[None, None, None]: ... + def compile(self) -> None: ... + def get_declared_hook(self, method_name: str) -> typing.Any: ... + def add_from_dict(self) -> None: ... + def get_config(self, cls: Any = ...) -> typing.Type[BaseConfig]: ... + def get_to_dict_flags(self, cls: Any = ...) -> str: ... + def get_from_dict_flags(self, cls: Any = ...) -> str: ... + def get_to_dict_default_flag_values(self, cls: Any = ...) -> str: ... + def get_from_dict_default_flag_values(self, cls: Any = ...) -> str: ... + def is_code_generation_option_enabled(self, option: str, cls: Any = ...) -> bool: ... + def add_to_dict(self) -> None: ... diff --git a/third-party-stubs/mashumaro/core/meta/helpers.pyi b/third-party-stubs/mashumaro/core/meta/helpers.pyi new file mode 100644 index 00000000000..112a5a078ba --- /dev/null +++ b/third-party-stubs/mashumaro/core/meta/helpers.pyi @@ -0,0 +1,37 @@ +import typing +from typing import Any + +def get_type_origin(t: Any): ... +def get_generic_name(t: Any, short: bool = ...) -> str: ... +def get_args(t: typing.Any) -> typing.Tuple[typing.Any, ...]: ... +def get_literal_values(t: typing.Any) -> Any: ... +def type_name( + t: typing.Any, + short: bool = ..., + type_vars: typing.Dict[str, typing.Any] = ..., + is_type_origin: bool = ..., + none_type_as_none: bool = ..., +) -> str: ... +def is_special_typing_primitive(t: Any) -> bool: ... +def is_generic(t: Any): ... +def is_typed_dict(t: Any) -> bool: ... +def is_named_tuple(t: Any) -> bool: ... +def is_new_type(t: Any) -> bool: ... +def is_union(t: Any): ... +def is_optional(t: Any, type_vars: typing.Dict[str, typing.Any] = ...) -> bool: ... +def is_annotated(t: Any) -> bool: ... +def is_literal(t: Any) -> bool: ... +def not_none_type_arg( + args: typing.Tuple[typing.Any, ...], type_vars: typing.Dict[str, typing.Any] = ... +) -> Any: ... +def is_type_var(t: Any) -> bool: ... +def is_type_var_any(t: Any) -> bool: ... +def is_class_var(t: Any) -> bool: ... +def is_init_var(t: Any) -> bool: ... +def get_class_that_defines_method(method_name: Any, cls: Any): ... +def get_class_that_defines_field(field_name: Any, cls: Any): ... +def is_dataclass_dict_mixin(t: Any) -> bool: ... +def is_dataclass_dict_mixin_subclass(t: Any) -> bool: ... +def resolve_type_vars(cls, arg_types: Any = ..., is_cls_created: bool = ...): ... +def get_name_error_name(e: NameError) -> str: ... +def is_dialect_subclass(t: Any) -> bool: ... diff --git a/third-party-stubs/mashumaro/meta/patch.pyi b/third-party-stubs/mashumaro/core/meta/patch.pyi similarity index 100% rename from third-party-stubs/mashumaro/meta/patch.pyi rename to third-party-stubs/mashumaro/core/meta/patch.pyi diff --git a/third-party-stubs/mashumaro/dialect.pyi b/third-party-stubs/mashumaro/dialect.pyi new file mode 100644 index 00000000000..330c9cfa1c1 --- /dev/null +++ b/third-party-stubs/mashumaro/dialect.pyi @@ -0,0 +1,7 @@ +from mashumaro.types import SerializationStrategy +from typing import Any, Callable, Dict, Union + +SerializationStrategyValueType = Union[SerializationStrategy, Dict[str, Union[str, Callable]]] + +class Dialect: + serialization_strategy: Dict[Any, SerializationStrategyValueType] = ... diff --git a/third-party-stubs/mashumaro/dialects/__init__.pyi b/third-party-stubs/mashumaro/dialects/__init__.pyi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/third-party-stubs/mashumaro/dialects/msgpack.pyi b/third-party-stubs/mashumaro/dialects/msgpack.pyi new file mode 100644 index 00000000000..f28b7c38283 --- /dev/null +++ b/third-party-stubs/mashumaro/dialects/msgpack.pyi @@ -0,0 +1,5 @@ +from mashumaro.dialect import Dialect +from typing import Any + +class MessagePackDialect(Dialect): + serialization_strategy: Any = ... diff --git a/third-party-stubs/mashumaro/exceptions.pyi b/third-party-stubs/mashumaro/exceptions.pyi index 09a608d4f2b..093eb7aa71f 100644 --- a/third-party-stubs/mashumaro/exceptions.pyi +++ b/third-party-stubs/mashumaro/exceptions.pyi @@ -1,4 +1,4 @@ -from mashumaro.meta.helpers import type_name as type_name +from mashumaro.core.meta.helpers import type_name as type_name from typing import Any, Optional class MissingField(LookupError): @@ -26,6 +26,16 @@ class UnserializableField(UnserializableDataError): @property def holder_class_name(self): ... +class UnsupportedSerializationEngine(UnserializableField): + def __init__( + self, field_name: Any, field_type: Any, holder_class: Any, engine: Any + ) -> None: ... + +class UnsupportedDeserializationEngine(UnserializableField): + def __init__( + self, field_name: Any, field_type: Any, holder_class: Any, engine: Any + ) -> None: ... + class InvalidFieldValue(ValueError): field_name: Any = ... field_type: Any = ... @@ -44,3 +54,22 @@ class InvalidFieldValue(ValueError): def field_type_name(self): ... @property def holder_class_name(self): ... + +class BadHookSignature(TypeError): ... + +class ThirdPartyModuleNotFoundError(ModuleNotFoundError): + module_name: Any = ... + field_name: Any = ... + holder_class: Any = ... + def __init__(self, module_name: Any, field_name: Any, holder_class: Any) -> None: ... + @property + def holder_class_name(self): ... + +class UnresolvedTypeReferenceError(NameError): + holder_class: Any = ... + name: Any = ... + def __init__(self, holder_class: Any, unresolved_type_name: Any) -> None: ... + @property + def holder_class_name(self): ... + +class BadDialect(ValueError): ... diff --git a/third-party-stubs/mashumaro/helper.pyi b/third-party-stubs/mashumaro/helper.pyi new file mode 100644 index 00000000000..acc7c6b50b3 --- /dev/null +++ b/third-party-stubs/mashumaro/helper.pyi @@ -0,0 +1,24 @@ +from mashumaro.types import SerializationStrategy +from typing import Any, Callable, Optional, Union +from typing_extensions import Literal + +NamedTupleDeserializationEngine = Literal["as_dict", "as_list"] +DateTimeDeserializationEngine = Literal["ciso8601", "pendulum"] +AnyDeserializationEngine = Literal[NamedTupleDeserializationEngine, DateTimeDeserializationEngine] + +NamedTupleSerializationEngine = Literal["as_dict", "as_list"] +AnySerializationEngine = NamedTupleSerializationEngine + +def field_options( + serialize: Optional[Union[AnySerializationEngine, Callable[[Any], Any]]] = ..., + deserialize: Optional[Union[AnyDeserializationEngine, Callable[[Any], Any]]] = ..., + serialization_strategy: Optional[SerializationStrategy] = ..., + alias: Optional[str] = ..., +) -> Any: ... + +class _PassThrough(SerializationStrategy): + def __call__(self, *args: Any, **kwargs: Any) -> None: ... + def serialize(self, value: Any): ... + def deserialize(self, value: Any): ... + +pass_through: Any diff --git a/third-party-stubs/mashumaro/meta/helpers.pyi b/third-party-stubs/mashumaro/meta/helpers.pyi deleted file mode 100644 index a176cc07dda..00000000000 --- a/third-party-stubs/mashumaro/meta/helpers.pyi +++ /dev/null @@ -1,11 +0,0 @@ -from typing import Any - -def get_imported_module_names(): ... -def get_type_origin(t: Any): ... -def type_name(t: Any): ... -def is_special_typing_primitive(t: Any): ... -def is_generic(t: Any): ... -def is_union(t: Any): ... -def is_type_var(t: Any): ... -def is_class_var(t: Any): ... -def is_init_var(t: Any): ... diff --git a/third-party-stubs/mashumaro/meta/macros.pyi b/third-party-stubs/mashumaro/meta/macros.pyi deleted file mode 100644 index c44b85e172a..00000000000 --- a/third-party-stubs/mashumaro/meta/macros.pyi +++ /dev/null @@ -1,6 +0,0 @@ -from typing import Any - -PY_36: Any -PY_37: Any -PY_38: Any -PY_39: Any diff --git a/third-party-stubs/mashumaro/mixins/__init__.pyi b/third-party-stubs/mashumaro/mixins/__init__.pyi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/third-party-stubs/mashumaro/mixins/dict.pyi b/third-party-stubs/mashumaro/mixins/dict.pyi new file mode 100644 index 00000000000..f0dc01f85f3 --- /dev/null +++ b/third-party-stubs/mashumaro/mixins/dict.pyi @@ -0,0 +1,15 @@ +from typing import Any, Dict, Mapping, Type, TypeVar + +T = TypeVar("T", bound="DataClassDictMixin") + +class DataClassDictMixin: + def __init_subclass__(cls: Type[T], **kwargs: Any) -> None: ... + def to_dict(self, omit_none: bool = True, validate: bool = False) -> dict: ... + @classmethod + def from_dict(cls, d: Mapping, validate=True) -> Any: ... + @classmethod + def __pre_deserialize__(cls: Type[T], d: Dict[Any, Any]) -> Dict[Any, Any]: ... + @classmethod + def __post_deserialize__(cls: Type[T], obj: T) -> T: ... + def __pre_serialize__(self) -> T: ... + def __post_serialize__(self, d: Dict[Any, Any]) -> Dict[Any, Any]: ... diff --git a/third-party-stubs/mashumaro/mixins/json.pyi b/third-party-stubs/mashumaro/mixins/json.pyi new file mode 100644 index 00000000000..14066559f31 --- /dev/null +++ b/third-party-stubs/mashumaro/mixins/json.pyi @@ -0,0 +1,19 @@ +from mashumaro.mixins.dict import DataClassDictMixin as DataClassDictMixin +from typing import Any, Dict, Type, TypeVar, Union +from typing_extensions import Protocol as Protocol + +EncodedData = Union[str, bytes, bytearray] +T = TypeVar("T", bound="DataClassJSONMixin") + +class Encoder: + def __call__(self, obj: Any, **kwargs: Any) -> EncodedData: ... + +class Decoder: + def __call__(self, s: EncodedData, **kwargs: Any) -> Dict[Any, Any]: ... + +class DataClassJSONMixin(DataClassDictMixin): + def to_json(self, encoder: Encoder = ..., **to_dict_kwargs: Any) -> EncodedData: ... + @classmethod + def from_json( + cls: Type[T], data: EncodedData, decoder: Decoder = ..., **from_dict_kwargs: Any + ) -> T: ... diff --git a/third-party-stubs/mashumaro/mixins/msgpack.pyi b/third-party-stubs/mashumaro/mixins/msgpack.pyi new file mode 100644 index 00000000000..b75b35488a5 --- /dev/null +++ b/third-party-stubs/mashumaro/mixins/msgpack.pyi @@ -0,0 +1,24 @@ +from mashumaro.dialects.msgpack import MessagePackDialect as MessagePackDialect +from mashumaro.mixins.dict import DataClassDictMixin as DataClassDictMixin +from typing import Any, Dict, Type, TypeVar +from typing_extensions import Protocol as Protocol + +EncodedData = bytes +T = TypeVar("T", bound="DataClassMessagePackMixin") +DEFAULT_DICT_PARAMS: Any + +class Encoder: + def __call__(self, o: Any, **kwargs: Any) -> EncodedData: ... + +class Decoder: + def __call__(self, packed: EncodedData, **kwargs: Any) -> Dict[Any, Any]: ... + +def default_encoder(data: Any) -> EncodedData: ... +def default_decoder(data: EncodedData) -> Dict[Any, Any]: ... + +class DataClassMessagePackMixin(DataClassDictMixin): + def to_msgpack(self, encoder: Encoder = ..., **to_dict_kwargs: Any) -> EncodedData: ... + @classmethod + def from_msgpack( + cls: Type[T], data: EncodedData, decoder: Decoder = ..., **from_dict_kwargs: Any + ) -> T: ... diff --git a/third-party-stubs/mashumaro/mixins/yaml.pyi b/third-party-stubs/mashumaro/mixins/yaml.pyi new file mode 100644 index 00000000000..4033741163b --- /dev/null +++ b/third-party-stubs/mashumaro/mixins/yaml.pyi @@ -0,0 +1,25 @@ +from mashumaro.mixins.dict import DataClassDictMixin as DataClassDictMixin +from typing import Any, Dict, Type, TypeVar, Union +from typing_extensions import Protocol as Protocol + +EncodedData = Union[str, bytes] +T = TypeVar("T", bound="DataClassYAMLMixin") + +class Encoder: + def __call__(self, o: Any, **kwargs: Any) -> EncodedData: ... + +class Decoder: + def __call__(self, packed: EncodedData, **kwargs: Any) -> Dict[Any, Any]: ... + +DefaultLoader: Any +DefaultDumper: Any + +def default_encoder(data: Any) -> EncodedData: ... +def default_decoder(data: EncodedData) -> Dict[Any, Any]: ... + +class DataClassYAMLMixin(DataClassDictMixin): + def to_yaml(self, encoder: Encoder = ..., **to_dict_kwargs: Any) -> EncodedData: ... + @classmethod + def from_yaml( + cls: Type[T], data: EncodedData, decoder: Decoder = ..., **from_dict_kwargs: Any + ) -> T: ... diff --git a/third-party-stubs/mashumaro/serializer/base/__init__.pyi b/third-party-stubs/mashumaro/serializer/base/__init__.pyi deleted file mode 100644 index 2a72874963c..00000000000 --- a/third-party-stubs/mashumaro/serializer/base/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -from .dict import DataClassDictMixin as DataClassDictMixin diff --git a/third-party-stubs/mashumaro/serializer/base/dict.pyi b/third-party-stubs/mashumaro/serializer/base/dict.pyi deleted file mode 100644 index 87beffa6d2b..00000000000 --- a/third-party-stubs/mashumaro/serializer/base/dict.pyi +++ /dev/null @@ -1,22 +0,0 @@ -from typing import Any, Mapping, Dict, Optional - -class DataClassDictMixin: - def __init_subclass__(cls, **kwargs: Any) -> None: ... - def __pre_serialize__(self) -> Any: ... - def __post_serialize__(self, dct: Mapping) -> Any: ... - @classmethod - def __pre_deserialize__(cls: Any, dct: Mapping) -> Any: ... - # This is absolutely totally wrong. This is *not* the signature of the Mashumaro to_dict - # But mypy insists that the DataClassDictMixin to_dict and the JsonSchemaMixin to_dict - # must have the same signatures now that we have an 'omit_none' flag on the Mashumaro to_dict. - # There is no 'validate = False' in Mashumaro. - # Could not find a way to tell mypy to ignore it. - def to_dict(self, omit_none=False, validate=False) -> dict: ... - @classmethod - def from_dict( - cls, - d: Mapping, - use_bytes: bool = False, - use_enum: bool = False, - use_datetime: bool = False, - ) -> Any: ... diff --git a/third-party-stubs/mashumaro/serializer/base/helpers.pyi b/third-party-stubs/mashumaro/serializer/base/helpers.pyi deleted file mode 100644 index f286a1a95d1..00000000000 --- a/third-party-stubs/mashumaro/serializer/base/helpers.pyi +++ /dev/null @@ -1,3 +0,0 @@ -from typing import Any - -def parse_timezone(s: str) -> Any: ... diff --git a/third-party-stubs/mashumaro/serializer/base/metaprogramming.pyi b/third-party-stubs/mashumaro/serializer/base/metaprogramming.pyi deleted file mode 100644 index 4450eea05e6..00000000000 --- a/third-party-stubs/mashumaro/serializer/base/metaprogramming.pyi +++ /dev/null @@ -1,45 +0,0 @@ -from mashumaro.meta.helpers import * -from mashumaro.serializer.base.helpers import * -from base64 import decodebytes as decodebytes, encodebytes as encodebytes -from mashumaro.exceptions import ( - InvalidFieldValue as InvalidFieldValue, - MissingField as MissingField, - UnserializableDataError as UnserializableDataError, - UnserializableField as UnserializableField, -) -from mashumaro.meta.patch import patch_fromisoformat as patch_fromisoformat -from mashumaro.types import ( - SerializableType as SerializableType, - SerializationStrategy as SerializationStrategy, -) -from typing import Any - -NoneType: Any -INITIAL_MODULES: Any - -class CodeBuilder: - cls: Any = ... - lines: Any = ... - modules: Any = ... - globals: Any = ... - def __init__(self, cls: Any) -> None: ... - def reset(self) -> None: ... - @property - def namespace(self): ... - @property - def annotations(self): ... - @property - def fields(self): ... - @property - def defaults(self): ... - def add_line(self, line: Any) -> None: ... - def indent(self) -> None: ... - def compile(self) -> None: ... - def add_from_dict(self) -> None: ... - def add_to_dict(self) -> None: ... - def add_pack_union( - self, fname: Any, ftype: Any, parent: Any, variant_types: Any, value_name: Any - ): ... - def add_unpack_union( - self, fname: Any, ftype: Any, parent: Any, variant_types: Any, value_name: Any - ): ... diff --git a/third-party-stubs/mashumaro/serializer/json.pyi b/third-party-stubs/mashumaro/serializer/json.pyi deleted file mode 100644 index 02282a3035e..00000000000 --- a/third-party-stubs/mashumaro/serializer/json.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from mashumaro.serializer.base import DataClassDictMixin as DataClassDictMixin -from typing import Any, Callable, Dict, Mapping, Type, TypeVar, Union - -DEFAULT_DICT_PARAMS: Any -EncodedData = Union[str, bytes, bytearray] -Encoder = Callable[[Dict], EncodedData] -Decoder = Callable[[EncodedData], Dict] -T = TypeVar("T", bound="DataClassJSONMixin") - -class DataClassJSONMixin(DataClassDictMixin): - def to_json( - self, encoder: Encoder = ..., dict_params: Mapping = ..., **encoder_kwargs: Any - ) -> EncodedData: ... - @classmethod - def from_json( - cls: Type[T], - data: EncodedData, - decoder: Decoder = ..., - dict_params: Mapping = ..., - **decoder_kwargs: Any, - ) -> DataClassDictMixin: ... diff --git a/third-party-stubs/mashumaro/serializer/msgpack.pyi b/third-party-stubs/mashumaro/serializer/msgpack.pyi deleted file mode 100644 index c520576a8bd..00000000000 --- a/third-party-stubs/mashumaro/serializer/msgpack.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from mashumaro.serializer.base import DataClassDictMixin as DataClassDictMixin -from typing import Any, Callable, Dict, Mapping, Type, TypeVar, Union - -DEFAULT_DICT_PARAMS: Any -EncodedData = Union[str, bytes, bytearray] -Encoder = Callable[[Dict], EncodedData] -Decoder = Callable[[EncodedData], Dict] -T = TypeVar("T", bound="DataClassMessagePackMixin") - -class DataClassMessagePackMixin(DataClassDictMixin): - def to_msgpack( - self, encoder: Encoder = ..., dict_params: Mapping = ..., **encoder_kwargs: Any - ) -> EncodedData: ... - @classmethod - def from_msgpack( - cls: Type[T], - data: EncodedData, - decoder: Decoder = ..., - dict_params: Mapping = ..., - **decoder_kwargs: Any, - ) -> DataClassDictMixin: ... diff --git a/third-party-stubs/mashumaro/serializer/yaml.pyi b/third-party-stubs/mashumaro/serializer/yaml.pyi deleted file mode 100644 index 74151f68b4e..00000000000 --- a/third-party-stubs/mashumaro/serializer/yaml.pyi +++ /dev/null @@ -1,21 +0,0 @@ -from mashumaro.serializer.base import DataClassDictMixin as DataClassDictMixin -from typing import Any, Callable, Dict, Mapping, Type, TypeVar, Union - -DEFAULT_DICT_PARAMS: Any -EncodedData = Union[str, bytes] -Encoder = Callable[[Dict], EncodedData] -Decoder = Callable[[EncodedData], Dict] -T = TypeVar("T", bound="DataClassYAMLMixin") - -class DataClassYAMLMixin(DataClassDictMixin): - def to_yaml( - self, encoder: Encoder = ..., dict_params: Mapping = ..., **encoder_kwargs: Any - ) -> EncodedData: ... - @classmethod - def from_yaml( - cls: Type[T], - data: EncodedData, - decoder: Decoder = ..., - dict_params: Mapping = ..., - **decoder_kwargs: Any, - ) -> T: ... diff --git a/third-party-stubs/mashumaro/types.pyi b/third-party-stubs/mashumaro/types.pyi index bab8489034e..ca63363c51c 100644 --- a/third-party-stubs/mashumaro/types.pyi +++ b/third-party-stubs/mashumaro/types.pyi @@ -1,23 +1,16 @@ -from typing import Any, Optional, TypeVar, Generic +import decimal +from typing import Any, Optional -TV = TypeVar("TV") - -class SerializableEncoder(Generic[TV]): - @classmethod - def _serialize(cls, value): ... - @classmethod - def _deserialize(cls, value): ... - -class SerializableType: - def _serialize(self): ... - @classmethod - def _deserialize(cls, value): ... +class SerializableType: ... +class GenericSerializableType: ... class SerializationStrategy: - def _serialize(self, value): ... - def _deserialize(self, value): ... + def serialize(self, value: Any) -> Any: ... + def deserialize(self, value: Any) -> Any: ... class RoundedDecimal(SerializationStrategy): exp: Any = ... rounding: Any = ... def __init__(self, places: Optional[Any] = ..., rounding: Optional[Any] = ...) -> None: ... + def serialize(self, value: Any) -> str: ... + def deserialize(self, value: str) -> Any: ... From a49f46de6a0e2bfe65fb09f7dbd224639d8b9a6f Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Wed, 20 Jul 2022 11:49:27 -0400 Subject: [PATCH 2/4] bump mashumaro version to 3.0.3 --- core/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/setup.py b/core/setup.py index 1bb52f87e63..21dde4ba297 100644 --- a/core/setup.py +++ b/core/setup.py @@ -56,7 +56,7 @@ "hologram>=0.0.14,<=0.0.15", "isodate>=0.6,<0.7", "logbook>=1.5,<1.6", - "mashumaro[msgpack]==3.0.1", + "mashumaro[msgpack]==3.0.3", "minimal-snowplow-tracker==0.0.2", "networkx>=2.3,<2.8.1;python_version<'3.8'", "networkx>=2.3,<3;python_version>='3.8'", From 0bf6d9b89ad692cfa39b2af3f34429e6092d071a Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Wed, 20 Jul 2022 11:52:32 -0400 Subject: [PATCH 3/4] Add changie --- .changes/unreleased/Under the Hood-20220720-115226.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20220720-115226.yaml diff --git a/.changes/unreleased/Under the Hood-20220720-115226.yaml b/.changes/unreleased/Under the Hood-20220720-115226.yaml new file mode 100644 index 00000000000..5f7dc732229 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20220720-115226.yaml @@ -0,0 +1,7 @@ +kind: Under the Hood +body: Update mashumaro to 3.0.3 +time: 2022-07-20T11:52:26.210876-04:00 +custom: + Author: gshank + Issue: "4940" + PR: "5118" From b72044557d733a18ea671b5323b0349ac5ed942b Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Wed, 20 Jul 2022 12:08:05 -0400 Subject: [PATCH 4/4] add pyyaml as a setup requirement --- core/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/core/setup.py b/core/setup.py index 21dde4ba297..a2ca18da4f8 100644 --- a/core/setup.py +++ b/core/setup.py @@ -69,6 +69,7 @@ "requests<3.0.0", "idna>=2.5,<4", "cffi>=1.9,<2.0.0", + "pyyaml>=6.0", ], zip_safe=False, classifiers=[