We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The code defining ManifestVersion in "Combining Pydantic and semver" documentation
ManifestVersion
python-semver/docs/advanced/combine-pydantic-and-semver.rst
Lines 17 to 60 in 1f08632
has a bug when ManifestVersion is used for serialization to JSON, resulting in the following raised exception:
pydantic_core._pydantic_core.PydanticSerializationError: Error calling function `<lambda>`: AttributeError: 'Version' object has no attribute 'x'
from pydantic import TypeAdapter from semver import Version version = Version.parse('1.2.3') json_version = TypeAdapter(ManifestVersion).dump_json(version)
is described in the following pytest module. (with the ManifestVersion defined in __init__.py.)
__init__.py
import json import pytest from pydantic import TypeAdapter from semver import Version from . import ManifestVersion @pytest.mark.parametrize( 'version', [ '0.0.1', '1.9.8', '2.3.4-rc+generic', '11.12.13-0.1.2', ], ) def test_serialize(version): expected_json = json.dumps(version).encode() expected_python = version = Version.parse(version) result_python = TypeAdapter(ManifestVersion).dump_python(version) result_json = TypeAdapter(ManifestVersion).dump_json(version) assert result_python == expected_python assert result_json == expected_json
Change
Lines 49 to 51 in 1f08632
to
serialization = core_schema.to_string_ser_schema(),
The text was updated successfully, but these errors were encountered:
a951c8a
Merge pull request #430 from apiwat-chantawibul/fix-semver-pydantic-s…
bd313ed
…erialization Fix #429: bug on serialization to json
Thanks a lot! Merged and happy! 👍
Sorry, something went wrong.
No branches or pull requests
Situation
The code defining
ManifestVersion
in "Combining Pydantic and semver" documentationpython-semver/docs/advanced/combine-pydantic-and-semver.rst
Lines 17 to 60 in 1f08632
has a bug when
ManifestVersion
is used for serialization to JSON, resulting in the following raised exception:To Reproduce
Expected Behavior
is described in the following pytest module.
(with the
ManifestVersion
defined in__init__.py
.)Solution
Change
python-semver/docs/advanced/combine-pydantic-and-semver.rst
Lines 49 to 51 in 1f08632
to
The text was updated successfully, but these errors were encountered: