Skip to content
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

Require pydantic<2.0 unless it's supported #573

Merged
merged 1 commit into from
Jul 1, 2023

Conversation

borzunov
Copy link
Member

@borzunov borzunov commented Jul 1, 2023

Pydantic 2.0 has been released yesterday and is not compatible with the current code.

Without this fix, tests fail with:

  File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pydantic/_internal/_generate_schema.py", line 285, in _generate_schema_for_type
    schema = self._generate_schema(obj)
  File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pydantic/_internal/_generate_schema.py", line 537, in _generate_schema
    return self._arbitrary_type_schema(obj, obj)
  File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/pydantic/_internal/_generate_schema.py", line 579, in _arbitrary_type_schema
    f'Unable to generate pydantic-core schema for {obj!r}. '
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'hivemind.dht.schema.conbytes.<locals>.ConstrainedBytesWithRegex'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.

If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.

@codecov
Copy link

codecov bot commented Jul 1, 2023

Codecov Report

Merging #573 (b6fbbdc) into master (11d70fe) will increase coverage by 0.14%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #573      +/-   ##
==========================================
+ Coverage   85.28%   85.43%   +0.14%     
==========================================
  Files          81       81              
  Lines        8004     8004              
==========================================
+ Hits         6826     6838      +12     
+ Misses       1178     1166      -12     

see 4 files with indirect coverage changes

@borzunov borzunov merged commit b7cbd97 into master Jul 1, 2023
@borzunov borzunov deleted the pydantic-less-than-2.0 branch July 1, 2023 23:32
borzunov added a commit to bigscience-workshop/petals that referenced this pull request Jul 1, 2023
mryab pushed a commit that referenced this pull request Jul 23, 2023
Pydantic 2.0 has been released yesterday and is not compatible with the current code.

(cherry picked from commit b7cbd97)
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