Open Pentusha opened 1 year ago
If anyone is interested in a workaround with monkeypatch:
import pydantic
from pydantic_settings import BaseSettings
pydantic.BaseSettings = BaseSettings
class AppContainer(containers.DeclarativeContainer):
config = providers.Configuration(strict=True)
env = providers.Configuration(strict=True, pydantic_settings=[env_secrets])
...
You do not really need to monkeypatch anything:
-container.config.from_pydantic(settings)
+container.config.from_dict(settings.model_dump())
from_pydantic
did essentially the same:
Hey @rmk135, Any chance that this issue will be considered soon? Many thanks for considering this request.
Is this package maintained?
The major version of
Pydantic
was recently released and lost backward compatibility. In particular, the.from_pydantic
method stopped working forproviders.Configuration
due to the fact that theBaseSettings
class now needs to be imported from a new package calledpydantic-settings
.