Compatibility with Pydantic v2
willem-hpe opened this issue · 3 comments
Is your feature request related to a problem? Please describe.
It is not currently possible to use fastapi-cloudevents in projects which use Pydantic v2. My organisation is currently using the plugin in a new service, but we need the service to support Pydantic v2 to allow us to take advantage of its performance benefits.
We have bumped cloudevents[pydantic] to 1.10.0, which does support Pydantic v2, but currently fastapi-cloudevents version 1.1.0 fails to import with the following error:
../../.pyenv/versions/3.11.5/envs/redacted-service-name/lib/python3.11/site-packages/fastapi_cloudevents/settings.py:4: in <module>
from pydantic import BaseSettings, Field
E pydantic.errors.PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.4/migration/#basesettings-has-moved-to-pydantic-settings for more details.
Describe the solution you'd like
A version of fastapi-cloudevents which supports Pydantic v2 would be ideal. Alternatively, a version which has Pydantic namespaced to allow it to work with v1 or v2 depending on what the downstream package has available would also solve this.
Describe alternatives you've considered
We planned to submit a PR to namespace Pydantic to allow cross-compatibility, but we found the main branch was already updated to support Pydantic v2, so the PR would probably introduce regressions rather than solve problems.
We would be willing to submit a PR based on the 1.1.0 tag if that would make it easier to solve this short term.
Hey @willem-hpe ,
Yes, we already have updated the package to support pydantic v2. See #9.
I don't have time to release the package because we are at war, and I was called to the Military.
Hopefully will get to it in a few days.
As a workaround you can install the package from source until we release v2.0.0 of this package
Hi @sasha-tkachev,
Understood. Hoping for your safe return.
@willem-hpe
Just released v2.0.0