Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 35da4f6

Browse filesBrowse 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
Copy full SHA for 35da4f6

File tree

2 files changed

+6
-1
lines changed
Filter options

2 files changed

+6
-1
lines changed

‎changelog.d/pr392.doc.rst

Copy file name to clipboard
+1Lines 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

Copy file name to clipboardExpand all lines: docs/advanced/combine-pydantic-and-semver.rst
+5-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.