Features & fixes:
- Support type aliases defined using the type statement (PEP 695).
- Fix type hint for
child_fieldsparameter ofUnionFieldto acceptFieldsubclasses.
Features & fixes:
- Fix inclusion of py.typed in wheel.
Breaking changes:
- The type annotations now require mypy 1.0 or higher to validate correctly.
Features & fixes:
- Create values for fields of non-
listordictcomposite types (such asfrozensetorOrderedDict) as that type, instead oflistordict. - Allow overriding the field for specific composite types through the
serializer_field_mappingdictionary. - Don't set optional fields to
rest_framework.fields.emptysentinel value when used in non-partial mode. This fixes occasional leaks of the sentinel into dataclasses returned to the user, for example when aDataclassSerializerwas nested inside a regular serializer. Not setting, and later stripping, the sentinels also increases performance. - Support dataclasses with fields that have
init=False. - Support
save()on serializers withmany=True. - Support for fields with union types.
- Support nested serializers with
source='*'. - Fix
child_kwargsdefined in dataclass field metadata (as opposed toextra_kwargsfield onMetasubclass).
Features & fixes:
- Allow all types, including special forms such as unions, to have their field type overridden through the
serializer_field_mappingdictionary. - Also treat unions containing
Noneas optional if they consist of three or more members. Previously this was only the case for unions with two members (i.e. only unions of a type withNonewere optional). - Many added and fixed type hints.
Features & fixes:
- Fix usage of PEP 585 generics with forward references (e.g.
list["str"]). - Fix usage of
allow_emptywithmany=True.
Features & fixes:
- Allow using the new
X | Noneunion syntax for specifying optional fields in Python 3.10+ (PEP 604).
Features & fixes:
- Allow serialization of properties created using @property decorator.
- Allow dataclass types to be serialized by a type not inheriting from
DataclassSerializer(usually aField).
Features & fixes:
- Fix
EnumFieldcompatibility with drf-yasg.
Breaking changes:
- The serializer field for dataclass fields that have a default value or default value factory, are now marked as
optional (
required=False). - Marking dataclass fields with
typing.Optionalno longer causes the serializer fields to be optional (they will still be marked as nullable). In previous versions these fields would be optional, which broke if a field had no default value. Due to the previous change, the common case of fields marked withtyping.Optionalthat hadNoneas a default value have no change in behaviour. - Drop support for generic
typing.Finaltype hints (without the type specified), astyping.Finalwas never supposed to be used in this way, and Python 3.10 will drop support for it.
Features & fixes:
- Support overriding serializer for a nested dataclass using
serializer_field_mapping. - Support overriding serializer for all nested dataclasses using
serializer_dataclass_fieldproperty. - Support partial updates of nested dataclasses.
- Support bound type variables.
- Support field generation for enumerations.
- Support specifying serializer field configuration in dataclass field metadata.
- Fix value for non-specified optional fields in validated_data on serializers with
many=True.
Breaking changes:
- The
validated_datarepresentation no longer contains therest_framework.fields.emptysentinel value for unsupplied fields. This reverts the breaking change from v0.7.
Features & fixes:
- Don't install tests into distributed packages.
Breaking changes:
- The
validated_datarepresentation now contains therest_framework.fields.emptysentinel value for fields where no value was provided, instead of the default of the dataclass field. The value returned bysave()is unchanged. This was necessary to support partial updates.
Features & fixes:
- Improved Python 3.9 compatibility.
- Support partial updates.
- Support standard collection generics (PEP 585).
- Support non-generic
listanddicttypehints. - Support final fields (PEP 591).
- Support auto-generation for list or dictionaries of Any or variable type.
- Set default
max_digitsanddecimal_placesforDecimalField. - Improved error message when automatic field type deduction fails.
- Rewrite to
save()implementation to finally fix all issues with nested serializers. - Fix deserialization for fields using
sourceoption. - Fix explicit specification of a method in the
fieldsoption.
- Make optional fields on the dataclass optional on the serializer as well.
- Fix (de-)serialization of dataclass lists specified with
many=True. - Fix deserialization of nullable nested dataclasses.
- Raise error when field is both declared and is present in
extra_kwargs. - Raise error when non-existing fields are included in
fieldsoption. - Minor performance improvements.
- Automatically recognize
Literal-typed fields (PEP 586). - Fix deserialization of dataclasses inside dictionaries.
- Improve error message when encountering field with a special form type.
- Automatically recognize UUID fields.
- Fix saving with nested dataclasses.
- Support arbitrary nesting of dictionaries and lists.
- Support putting
__all__magic option infieldsoption on Meta class.
- Initial release.