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

Fix pydantic/semver example #392

New issue

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

Merged

Conversation

mssalvatore
Copy link
Contributor

The current example, when used with semver 3.0.0.dev4 and pydantic 1.10.4, produces the following error:

Traceback (most recent call last):
  File "/home/msalvatore/compost/semver_test/test.py", line 19, in <module>
    class MyModel(pydantic.BaseModel):
  File "pydantic/main.py", line 198, in pydantic.main.ModelMetaclass.__new__
  File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
  File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
  File "pydantic/fields.py", line 557, in pydantic.fields.ModelField.prepare
  File "pydantic/fields.py", line 834, in pydantic.fields.ModelField.populate_validators
  File "pydantic/class_validators.py", line 263, in pydantic.class_validators.prep_validators
  File "pydantic/class_validators.py", line 259, in pydantic.class_validators.make_generic_validator
  File "pydantic/class_validators.py", line 310, in pydantic.class_validators._generic_validator_basic
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.

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.
@mssalvatore mssalvatore force-pushed the fix-pydantic-semver-example branch from cd0f504 to 35da4f6 Compare January 31, 2023 14:06
@tomschr
Copy link
Member

tomschr commented Jan 31, 2023

Thank you very much @mssalvatore, this is great! 👍

@tomschr tomschr merged commit 2018346 into python-semver:master Jan 31, 2023
@mssalvatore mssalvatore deleted the fix-pydantic-semver-example branch January 31, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.