- Fix fields of type
Any
incorrectly always rejecting the valueNone
.None
can still be disallowed by explicitly setting the marshmallow attributeallow_none=False
. (#80)
- Fix an inconsistency in the behavior of
marshmallow.post_load
. The input topost_load
hooks was either a dict or a dataclass instance depending on the method name. It is now always a dict. (#75)
- Allow the use of BaseSchema to specify a custom mapping from python types to marshmallow fields (#72)
- Cache the generated schemas (#70)
- Exclude the
test
subdirectory from the published package. (#59)
- Fix behavior when
base_schema
is passed to a nested dataclass/schema (#52). Thanks @ADR-007-SoftServe for the catch and patch.
- Improved documentation
- The library now has more unit tests
dict
andlist
without type parameters are now supported
from 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 impact anyone since marshmallow-specific methods are still copied.
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")
- Dropped compatibility with marshmallow 2.
- Added support for the
Any
type