Skip to content

Commit 35da4f6

Browse files
committed
Fix pydantic/semver example
The current example, when used with semver 3.0.0.dev4 and pydantic 1.10.4, produces the following error: pydantic.errors.ConfigError: Invalid signature for validator <bound method Version.parse of <class '__main__.PydanticVersion'>>: (version: Union[str, bytes], optional_minor_and_patch: bool = False) -> 'Version', should be: (value, values, config, field), "values", "config" and "field" are all optional. This commit fixes the example in the documentation so that it works and does not raise an error.
1 parent 0ca281d commit 35da4f6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

changelog.d/pr392.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix the example in the documentation for combining semver and pydantic.

docs/advanced/combine-pydantic-and-semver.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ To work with Pydantic, use the following steps:
1717
from semver import Version
1818
1919
class PydanticVersion(Version):
20+
@classmethod
21+
def _parse(cls, version):
22+
return cls.parse(version)
23+
2024
@classmethod
2125
def __get_validators__(cls):
2226
"""Return a list of validator methods for pydantic models."""
23-
yield cls.parse
27+
yield cls._parse
2428
2529
@classmethod
2630
def __modify_schema__(cls, field_schema):

0 commit comments

Comments
 (0)
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