From 861b7ea1293b518c4bb628aa96a873f7277d3964 Mon Sep 17 00:00:00 2001 From: James Baker Kroner <9373098+jbkroner@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:08:14 -0500 Subject: [PATCH 1/4] update docs --- docs/advanced/combine-pydantic-and-semver.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/advanced/combine-pydantic-and-semver.rst b/docs/advanced/combine-pydantic-and-semver.rst index c7566e12..8744187f 100644 --- a/docs/advanced/combine-pydantic-and-semver.rst +++ b/docs/advanced/combine-pydantic-and-semver.rst @@ -9,7 +9,23 @@ According to its homepage, `Pydantic `_ "enforces type hints at runtime, and provides user friendly errors when data is invalid." -To work with Pydantic>2.0, use the following steps: +If you are working with Pydantic>2.0 and pydantic-extra-types>=2.10.0 you can use the built in `_VersionPydanticAnnotation` type, which wraps the `python-semver` `Version` type. + + .. code-block:: python + + from pydantic import BaseModel + + from pydantic_extra_types.server import _VersionPydanticAnnotation + + class appVersion(BaseModel): + version: _VersionPydanticAnnotation + + app_version = appVersion(version="1.2.3") + + print(app_version.version) + # > 1.2.3 + +To work with Pydantic>2.0 and without pydantic-extra-types you can use the following example to define your own type: 1. Derive a new class from :class:`~semver.version.Version` From cb68472cae4aa65072da45de047f2bd80eb87b09 Mon Sep 17 00:00:00 2001 From: Jim Kroner <9373098+jbkroner@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:56:34 -0500 Subject: [PATCH 2/4] Update docs/advanced/combine-pydantic-and-semver.rst Co-authored-by: Tom Schraitle --- docs/advanced/combine-pydantic-and-semver.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced/combine-pydantic-and-semver.rst b/docs/advanced/combine-pydantic-and-semver.rst index 8744187f..fc5ae480 100644 --- a/docs/advanced/combine-pydantic-and-semver.rst +++ b/docs/advanced/combine-pydantic-and-semver.rst @@ -9,7 +9,7 @@ According to its homepage, `Pydantic `_ "enforces type hints at runtime, and provides user friendly errors when data is invalid." -If you are working with Pydantic>2.0 and pydantic-extra-types>=2.10.0 you can use the built in `_VersionPydanticAnnotation` type, which wraps the `python-semver` `Version` type. +If you are working with Pydantic>2.0 and pydantic-extra-types>=2.10.0 use the built in `_VersionPydanticAnnotation` type, which wraps the :class:`Version ` class. .. code-block:: python From 802c0705611895d1e70e6f0b9ef76b75bee9e7a3 Mon Sep 17 00:00:00 2001 From: Jim Kroner <9373098+jbkroner@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:56:41 -0500 Subject: [PATCH 3/4] Update docs/advanced/combine-pydantic-and-semver.rst Co-authored-by: Tom Schraitle --- docs/advanced/combine-pydantic-and-semver.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced/combine-pydantic-and-semver.rst b/docs/advanced/combine-pydantic-and-semver.rst index fc5ae480..25171f15 100644 --- a/docs/advanced/combine-pydantic-and-semver.rst +++ b/docs/advanced/combine-pydantic-and-semver.rst @@ -25,7 +25,7 @@ If you are working with Pydantic>2.0 and pydantic-extra-types>=2.10.0 use the bu print(app_version.version) # > 1.2.3 -To work with Pydantic>2.0 and without pydantic-extra-types you can use the following example to define your own type: +To work with Pydantic>2.0 and without pydantic-extra-types use the following example to define your own type: 1. Derive a new class from :class:`~semver.version.Version` From fc327aff3b97afeed42eb7b56ab1741f71d8ce75 Mon Sep 17 00:00:00 2001 From: James Baker Kroner <9373098+jbkroner@users.noreply.github.com> Date: Fri, 4 Jul 2025 16:27:37 -0400 Subject: [PATCH 4/4] update example with pydantic 2.10.5 semantic_version type --- docs/advanced/combine-pydantic-and-semver.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/advanced/combine-pydantic-and-semver.rst b/docs/advanced/combine-pydantic-and-semver.rst index 25171f15..975fb418 100644 --- a/docs/advanced/combine-pydantic-and-semver.rst +++ b/docs/advanced/combine-pydantic-and-semver.rst @@ -9,16 +9,15 @@ According to its homepage, `Pydantic `_ "enforces type hints at runtime, and provides user friendly errors when data is invalid." -If you are working with Pydantic>2.0 and pydantic-extra-types>=2.10.0 use the built in `_VersionPydanticAnnotation` type, which wraps the :class:`Version ` class. +If you are working with Pydantic>2.0 and pydantic-extra-types>=2.10.5 use the built in `SemanticVersion` type, which wraps the :class:`Version ` class. .. code-block:: python from pydantic import BaseModel - - from pydantic_extra_types.server import _VersionPydanticAnnotation + from pydantic_extra_types.semantic_version import SemanticVersion class appVersion(BaseModel): - version: _VersionPydanticAnnotation + version: SemanticVersion app_version = appVersion(version="1.2.3") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy