From 1faed763e2d291222eb2c0b8072ed3543c2af0ec Mon Sep 17 00:00:00 2001 From: Abdeldjalil Hezouat Date: Mon, 18 Nov 2024 00:22:43 +0100 Subject: [PATCH 1/2] change old pydantic docs url --- docs/contrib/pydantic.rst | 12 ++++++------ tortoise/contrib/pydantic/base.py | 2 +- tortoise/contrib/pydantic/creator.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/contrib/pydantic.rst b/docs/contrib/pydantic.rst index b8226e6a4..919fd0b0d 100644 --- a/docs/contrib/pydantic.rst +++ b/docs/contrib/pydantic.rst @@ -54,7 +54,7 @@ Lets start with a basic Tortoise Model: Tournament_Pydantic = pydantic_model_creator(Tournament) -And now have a `Pydantic Model `__ that can be used for representing schema and serialisation. +And now have a `Pydantic Model `__ that can be used for representing schema and serialisation. The JSON-Schema of ``Tournament_Pydantic`` is now: @@ -92,7 +92,7 @@ To serialise an object it is simply *(in an async context)*: tournament = await Tournament.create(name="New Tournament") tourpy = await Tournament_Pydantic.from_tortoise_orm(tournament) -And one could get the contents by using `regular Pydantic-object methods `_, such as ``.model_dump()`` or ``.model_dump_json()`` +And one could get the contents by using `regular Pydantic-object methods `_, such as ``.model_dump()`` or ``.model_dump_json()`` .. code-block:: py3 @@ -150,7 +150,7 @@ Source to example: :ref:`example_pydantic_tut2` Tournament_Pydantic_List = pydantic_queryset_creator(Tournament) -And now have a `Pydantic Model `__ that can be used for representing schema and serialisation. +And now have a `Pydantic Model `__ that can be used for representing schema and serialisation. The JSON-Schema of ``Tournament_Pydantic_List`` is now: @@ -202,7 +202,7 @@ To serialise an object it is simply *(in an async context)*: tourpy = await Tournament_Pydantic_List.from_queryset(Tournament.all()) -And one could get the contents by using `regular Pydantic-object methods `_, such as ``.model_dump()`` or ``.model_dump_json()`` +And one could get the contents by using `regular Pydantic-object methods `_, such as ``.model_dump()`` or ``.model_dump_json()`` .. code-block:: py3 @@ -296,7 +296,7 @@ We define our models with a relationship: "models.Tournament", related_name="events", description="The Tournament this happens in" ) -Next we create our `Pydantic Model `__ using ``pydantic_model_creator``: +Next we create our `Pydantic Model `__ using ``pydantic_model_creator``: .. code-block:: py3 @@ -597,7 +597,7 @@ Note that the Pydantic serializer can't call async methods, but since the tortoi So we don't need to await the relation. We should however protect against the case where no prefetching was done, hence catching and handling the ``tortoise.exceptions.NoValuesFetched`` exception. -Next we create our `Pydantic Model `__ using ``pydantic_model_creator``: +Next we create our `Pydantic Model `__ using ``pydantic_model_creator``: .. code-block:: py3 diff --git a/tortoise/contrib/pydantic/base.py b/tortoise/contrib/pydantic/base.py index 920baf524..731807407 100644 --- a/tortoise/contrib/pydantic/base.py +++ b/tortoise/contrib/pydantic/base.py @@ -123,7 +123,7 @@ class PydanticListModel(RootModel): Pydantic BaseModel for List of Tortoise Models This provides an extra method above the usual Pydantic - `model properties `__ + `model properties `__ """ @classmethod diff --git a/tortoise/contrib/pydantic/creator.py b/tortoise/contrib/pydantic/creator.py index 8d0e3c828..9f974f461 100644 --- a/tortoise/contrib/pydantic/creator.py +++ b/tortoise/contrib/pydantic/creator.py @@ -156,7 +156,7 @@ def pydantic_queryset_creator( sort_alphabetically: Optional[bool] = None, ) -> Type[PydanticListModel]: """ - Function to build a `Pydantic Model `__ list off Tortoise Model. + Function to build a `Pydantic Model `__ list off Tortoise Model. :param cls: The Tortoise Model to put in a list. :param name: Specify a custom name explicitly, instead of a generated name. @@ -572,7 +572,7 @@ def pydantic_model_creator( module: str = __name__, ) -> Type[PydanticModel]: """ - Function to build `Pydantic Model `__ off Tortoise Model. + Function to build `Pydantic Model `__ off Tortoise Model. :param cls: The Tortoise Model :param name: Specify a custom name explicitly, instead of a generated name. From b37eba1094e9cd64cfab2351ea56d536f90eb88e Mon Sep 17 00:00:00 2001 From: Abdeldjalil Hezouat Date: Mon, 18 Nov 2024 00:24:38 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index bcbe2c4ed..060550a85 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -24,6 +24,9 @@ Added - Add POSIX Regex support for PostgreSQL and MySQL (#1714) - support app=None for tortoise.contrib.fastapi.RegisterTortoise (#1733) +Changed +^^^^^^^ +- Change old pydantic docs link to new one (#1775). 0.21.6 ------