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

ODMantic is incompatible with pydantic version 2.7.0 #451

Closed
MickVermeulen opened this issue Apr 12, 2024 · 4 comments · Fixed by #462
Closed

ODMantic is incompatible with pydantic version 2.7.0 #451

MickVermeulen opened this issue Apr 12, 2024 · 4 comments · Fixed by #462
Labels
bug Something isn't working

Comments

@MickVermeulen
Copy link

Bug

When updating to pydantic version 2.7.0, pydantic will throw a PydanticUserError due to ODMantic trying to use model_config as a model field name. More info: https://errors.pydantic.dev/2.7/u/model-config-invalid-field-name

Current Behavior

# assuming you have pydantic==2.7.0 installed
from odmantic import Model

class Foo(Model):
    foo: str

if __name__ == '__main__':
    foo = Foo(foo='bar') # raises pydantic.errors.PydanticUserError

Expected behavior

I expect it to not throw an error

Environment

  • ODMantic version: 1.0.1
  • Pydantic version: 2.7.0
  • MongoDB version: any
pydantic version: 2.7.0
pydantic-core version: 2.18.1
pydantic-core build: profile=release pgo=true
python version: 3.10.13 (main, Sep 11 2023, 08:16:02) [Clang 14.0.6 ]
platform: macOS-13.5.2-arm64-arm-64bit
related packages: typing_extensions-4.9.0 fastapi-0.110.1 pydantic-settings-2.2.1
@munishkhatri720
Copy link

The same issue occurred with me, but it was fixed by reverting the Pydantic version from 2.7.0 to 2.6.4.

@abhinna1
Copy link

Seems like Pydantic 2.70 had some major changes. You can read more here.

Reverting Pydantic version to any previous versions above 2.5.2, preferably 2.6.4 solves the issue for now.

@adriencaccia
Copy link
Collaborator

Thanks for the issue @MickVermeulen, #462 should fix it!
The release is coming soon.

@adriencaccia
Copy link
Collaborator

M1N0RM1N3R added a commit to M1N0RM1N3R/Kolkra-NG that referenced this issue May 10, 2024
The latest Pydantic version (2.7.0) is not compatible with ODMantic--see art049/odmantic#451
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants