Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency mashumaro to v1.24 #293

Merged
merged 1 commit into from
Jul 9, 2023

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Jul 9, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
mashumaro 1.13 -> 1.24 age adoption passing confidence

Release Notes

Fatal1ty/mashumaro (mashumaro)

v1.24

Compare Source

Changes

  • Added support for Union types. It's recommended to place more complex variant types at first place like Union[Dict[int, int], List[int]] not Union[List[int], Dict[int, int]]. When optional type validation is implemented it will be possible not to follow this rule.
  • It is now possible to use serialize and deserialize options for any third-party types and SerializableType classes if you need it for some reason.

v1.23

Compare Source

Changes

@​dataclass
class A(DataClassDictMixin):

    @​dataclass
    class B(DataClassDictMixin):
        b: int

    a: int
    b: B

print(A.from_dict({'a': 1, 'b': {'b': 2}}))

v1.22

Compare Source

Changes

  • Support for hooks declared in superclasses
class Counter:
    deserialize = 0
    serialize = 0

    @​classmethod
    def __pre_deserialize__(cls, d):
        Counter.deserialize += 1
        return d

    def __pre_serialize__(self):
        Counter.serialize += 1
        return self

@​dataclass
class Derived(Counter, DataClassDictMixin):
    a: int

obj = Derived.from_dict({"a": 1})
obj.to_dict()

print(Counter.deserialize)  # 1
print(Counter.serialize)  # 1

v1.21

Compare Source

Changes

v1.20

Compare Source

Changes

@​dataclass
class User(DataClassJSONMixin):
    name: str
    password: str
    is_deserialized: bool = False
    counter: ClassVar[int] = 0

    @​classmethod
    def __pre_deserialize__(cls, d: Dict[Any, Any]) -> Dict[Any, Any]:
        return {k.lower(): v for k, v in d.items()}

    @​classmethod
    def __post_deserialize__(cls, obj: "User") -> "User":
        obj.is_deserialized = True
        return obj

    def __pre_serialize__(self) -> "User":
        self.counter += 1
        return self

    def __post_serialize__(self, d: Dict[Any, Any]) -> Dict[Any, Any]:
        d.pop("password")
        return d

user = User.from_json('{"NAME": "Name", "PASSWORD": "secret"}')
print(user)  # User(name='Name', password='secret', is_deserialized=True)
print(user.to_json())  # {"name": "Name", "is_deserialized": true}
print(user.counter)  # 1

v1.19

Compare Source

Changes

  • Added support for serialize option:
@​dataclass
class A(DataClassDictMixin):
    dt: datetime = field(
        metadata={
            "serialize": lambda v: v.strftime('%Y-%m-%d %H:%M:%S')
        }
    )

v1.18

Compare Source

Changes

  • Fixed weird TypeError exception that was thrown instead of MissingField in case when field doesn't have default argument
  • Added ability to change deserialization method with metadata argument. See here for details.

v1.17

Compare Source

Changes

  • Support for all types from pathlib
  • Variable annotated with a class derived from os.PathLike will be deserialized into an instance of that class
  • Variable annotated with os.PathLike will be deserialized into an instance of PurePath class: PurePosixClass on posix, PureWindowsPath in windows

v1.16

Compare Source

Changes

  • Raise InvalidFieldValue with details in case deserialization fails.

v1.15

Compare Source

Fix for derived data classes with fields and default_factory in ancestors

In the previous versions if a data class had been derived from another data class with a default_factory, MissingField would have been raised on instantiation without field value provided as it shown in the following example:

@​dataclass()
class A(DataClassJSONMixin):
    foo: List[str] = field(default_factory=list)
 
@​dataclass()
class B(A):
    pass

print(B.from_dict({}))  # MissingField: Field "foo" of type typing.List[str] is missing in __main__.B instance

Thanks to @​ian-sentropy who found this bug.

v1.14

Compare Source

Features

  • Support Python 3.9

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot added chore dependencies Pull requests that update a dependency file labels Jul 9, 2023
@renovate renovate bot force-pushed the renovate/mashumaro-1.x branch 2 times, most recently from 459edb8 to 5a914a7 Compare July 9, 2023 13:42
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@renovate renovate bot force-pushed the renovate/mashumaro-1.x branch from 5a914a7 to 42957ee Compare July 9, 2023 14:57
@matfax matfax merged commit 68677c0 into main Jul 9, 2023
@matfax matfax deleted the renovate/mashumaro-1.x branch July 9, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant