Skip to content

Commit

Permalink
Update compat.django module docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
surenkov committed Mar 25, 2024
1 parent 14ddb34 commit 59203db
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions django_pydantic_field/compat/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
`typing.Union` and its special forms, like `typing.Optional`, have its own inheritance chain.
Moreover, `types.UnionType`, introduced in 3.10, do not allow explicit type construction,
only with `X | Y` syntax. Both cases require a dedicated serializer for migration writes.
[typing.Annotated](https://peps.python.org/pep-0593/)
`typing.Annotated` syntax is supported for direct field annotations, though I find it highly discouraged
while using in `schema=` attribute.
The limitation with `Annotated` types is that supplied metadata could be actually of any type.
In case of Pydantic, it is a `FieldInfo` objects, which are not compatible with Django Migrations serializers.
This module provides a few containers (`FieldInfoContainer` and `DataclassContainer`),
which allow Model serializers to work.
"""

from __future__ import annotations
Expand Down

0 comments on commit 59203db

Please sign in to comment.