Repository navigation
4.0.0a0
Pre-releaseFirst alpha release of FastDepends 4.0.
Breaking changes
- Drop Pydantic 1 support. The optional Pydantic integration now requires
pydantic>=2.12.5,<3. Projects using Pydantic 1 should remain on FastDepends 3.x. - Make
PydanticSerializer(...).encode(value)honor the instance's JSON encoding configuration. Existing integrations using this encoder now receive the configured output for ordinary values.
New APIs
- Add
call.serializer.get_schema(embed=False, exclude=(), resolve_refs=False)for external inputs, including dependency inputs, active provider overrides, aliases, and configuration. - Add
call.serializer.get_response_schema()for return-value JSON schemas. - Add
call.serializer.encode(value)for already validated handler results. With Pydantic, encoding uses the declared return type throughTypeAdapter, includingPlainSerializer,WrapSerializer, aliases, and model serialization. Direct model validation preserves custommodel_validate()overrides. - Add
CustomField.get_schema(parameter)andSchemaFieldto describe external inputs and group them by source, such as headers or query parameters.
Pydantic and Msgspec implement the schema API. Existing custom serializers can leave schema generation and encoding unimplemented until those methods are needed.
@inject continues to return validated Python values. Factory-level encode() remains a generic encoder; integrations select the serializer attached to a call to use that call's return annotation. Typed Pydantic encoding emits JSON even for root bytes, while the factory encoder continues to pass raw root bytes through. Msgspec retains its existing encoding behavior.
Pydantic remains optional. Msgspec and operation without either backend remain supported. Python 3.10+ is supported.
Install the alpha explicitly:
pip install 'fast-depends[pydantic]==4.0.0a0'Implemented in #318, incorporating #296, #297, #305, #306, #319, #320, and #321.
Full changelog: 3.0.11...4.0.0a0