NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #1880 most downloaded on PyPI
Python library to convert dataclasses into marshmallow schemas.
Last release 2 years ago
no release in 18 months
Ships fairly regularly
a new release about every 3 months
Most releases are documented
notes for 40 of 58 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
74 releases · first in 2019
Relax dependency pins for typeguard and typing-inspect. ([#273], [#272])
Add support for using Annotated (rather than our now deprecated custom NewType) to associate marshmallow configuration with particular types. ([#257])
Annotated (rather than our now deprecated
custom NewType) to associate marshmallow configuration with
particular types. (#257)Unions
of generic types. (#260, #261, #250)One column per quarter.
Update VERSION, (hopefully) really publish 8.6.1
Update VERSION, (hopefully) really publish 8.6.1
marshamallow_dataclass.dataclass decorator. (#258, thank you @mvanderlee!)class_schema. (#249)Union argument ordering in tests. Note that a
bug remains: semantically, Unions do not respect argument
order, yet order matters for de/serialization. (#248)This adds the ability to include non init-ed fields into the schema
include_non_init:
Pin typing-extensions>=2.4.0 to ensure support for the field_specifiers paramter of the dataclass_transform decorator. ([#240])
Pin typing-extensions>=2.4.0 to ensure support for the
field_specifiers paramter of the dataclass_transform decorator.
(#240)
Tighten pin on typing-inspect in an attempt to prevent
breakage from a hypothetical major version bump.
Tighten pin on typeguard to exclude older versions
for which our tests fail.
Fix to allow type-checkers to properly handle fields initialized by a dataclasses.Field instance. ([#239])
dataclasses.Field instance. (#239)Fixes to work with typeguard 3.x. ([#235], [#234])
Replace the use of marshmallow-enum with the native marshmallow.field.Enum (when using a sufficiently recent version of marshmallow). ([#227][], [#225
We now test under python version 3.11 (as well as 3.6 through 3.10). ([#220][])
We now test under python version 3.11 (as well as 3.6 through 3.10). (#220)
Recognize the variable-length, homogeneous tuple types Tuple[T, ...] (and tuple[T, ...] under python >= 3.8). These are
equivalent to the previously recognized Sequence[T]. (#221)
Recognize PEP 604, T | U, union notation (requires python >=
3.10). Fixes #194. (#219)
Fix [#206][]: NewType breakage with typing-inspect>=0.8.0 ([#207][], [#211][])
Nothing published for this version
Fix https://github.com/lovasoa/marshmallow_dataclass/issues/190
Fix bug introduced in previous release. See https://github.com/lovasoa/marshmallow_dataclass/pull/189
Fix slowdown introduced in v8.5.4. See https://github.com/lovasoa/marshmallow_dataclass/pull/187
Add support for the Final type. See #150 and #151
Fix spurious ValueError when defining a Union field with explicit default value
ValueError when defining a Union field with explicit default value
(#161)Fix spurious TypeError when serializing Optional union types with required=True
TypeError when serializing Optional union types with required=True
(#160)Allow setting required=True on fields of type Optional
Fix default warning coming from marshmallow. Bump minimal marshmallow version requirement to 3.13. See #157.
Compatibility with python3.9 lowercase type annotations. See #136
Fix compatibility with older python versions.
Add support for multiple `collections.abc` containers :
collections.abc containers :
You can now write :
from marshmallow_dataclass import dataclass
from collections.abc import Sequence, Mapping, Set
@dataclass
class FrozenData:
seq: Sequence[int] # like List[int], but immutable
map: Mapping[str, int] # like Dict[str, int], but immutable
set: Set[int] # like List[int], but unordered
f: FrozenData = FrozenData.Schema().load({"seq":[1], "map":{"x":2}, "set":[2]})
print(f.seq[0]) # -> 1
print(f.map["x"]) # -> 2
print(2 in f.set) # -> True
- Fix package license field
Allow None in Optional fields. See #108
None in Optional fields. See #108Export pre-built Email and Url types. See #115
Add support for the Literal type. See #110
Improved support for Optional types
Better support for unions (See #93).
CustomType = NewType("CustomType", str, validate=marshmallow.validate.Length(min=3))
@dataclass
class CustomObject:
some_field: CustomType = field(metadata={"validate": marshmallow.validate.URL()})
The following code will produce a field with the following list of validators: [marshmallow.validate.Length(min=3), marshmallow.validate.URL()] instead of the previous: [marshmallow.validate.URL()].Allow setting a custom marshmallow field for collection types. This lets you write code such as : ```python class FilteringListField(ListField): def _
class FilteringListField(ListField):
def __init__(self, cls: Union[Field, type], min: typing.Any, **kwargs):
super().__init__(cls, **kwargs)
self.min = min
def _deserialize(self, value, attr, data, **kwargs) -> typing.List[typing.Any]:
loaded = super(FilteringListField, self)._deserialize(
value, attr, data, **kwargs
)
return [x for x in loaded if self.min <= x]
class BaseSchema(Schema):
TYPE_MAPPING = {typing.List: FilteringListField}
@dataclasses.dataclass
class WithCustomField:
constrained_floats: typing.List[float] = dataclasses.field(metadata={"min": 1})
schema = class_schema(WithCustomField, base_schema=BaseSchema)()
schema.load({"constrained_floats": [0, 1, 2, 3]})
# -> WithCustomField(constrained_floats=[1.0, 2.0, 3.0])
(See #66)Fix fields of type Any incorrectly always rejecting the value None. None can still be disallowed by explicitly setting the marshmallow attribute allow
Any incorrectly always rejecting the value None.
None can still be disallowed by explicitly setting the marshmallow attribute allow_none=False.
(#80)Fix an inconsistency in the behavior of marshmallow.post_load. The input to `post_load` hooks was either a dict or a dataclass instance depending on t
Allow the use of BaseSchema to specify a custom mapping from python types to marshmallow fields
- Cache the generated schemas
Nothing published for this version
Exclude the test subdirectory from the published package.
test subdirectory from the published package.
(#59)Add mypy plugin that handles NewType (#50). Thanks @selimb.
Fix behavior when base_schema is passed to a nested dataclass/schema (#52). Thanks @ADR-007-SoftServe for the catch and patch.
base_schema is passed to a nested dataclass/schema
(#52).
Thanks @ADR-007-SoftServe
for the catch and patch.The library now has more unit tests
dict and list without type parameters are now supportedfrom marshmallow_dataclass import dataclass
@dataclass
class Environment:
env_variables: dict
However, we do still recommend you to always use explicit type parameters, that is:
from marshmallow_dataclass import dataclass
from typing import Dict
@dataclass
class Environment:
env_variables: Dict[str, str]
Methods are not copied from the dataclass to the generated Schema anymore. (See #47). This breaks backward compatibility, but hopefully should not imp
from marshmallow_dataclass import dataclass
@dataclass
class C:
def say_hello():
print("hello")
C.Schema.say_hello()
from marshmallow_dataclass import dataclass
from marshmallow import validates, ValidationError
@dataclass
class C:
name: str
@validates('name')
def validates(self, value):
if len(name) > 10: raise ValidationError("name too long")
- custom base schema - NewType declarations
Nothing published for this version
Nothing published for this version
Dropped compatibility with marshmallow 2.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
- Added support for the Any type
Any typeNothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →