diff --git a/changelog.d/pr392.doc.rst b/changelog.d/pr392.doc.rst new file mode 100644 index 00000000..e542cef9 --- /dev/null +++ b/changelog.d/pr392.doc.rst @@ -0,0 +1 @@ +Fix the example in the documentation for combining semver and pydantic. diff --git a/docs/advanced/combine-pydantic-and-semver.rst b/docs/advanced/combine-pydantic-and-semver.rst index a9249daf..a00c2cff 100644 --- a/docs/advanced/combine-pydantic-and-semver.rst +++ b/docs/advanced/combine-pydantic-and-semver.rst @@ -17,10 +17,14 @@ To work with Pydantic, use the following steps: from semver import Version class PydanticVersion(Version): + @classmethod + def _parse(cls, version): + return cls.parse(version) + @classmethod def __get_validators__(cls): """Return a list of validator methods for pydantic models.""" - yield cls.parse + yield cls._parse @classmethod def __modify_schema__(cls, field_schema):