class Settings(BaseSettings):
...
class Container(containers.DeclarativeContainer):
config = providers.Singleton(Settings)
...
I used pydantic settings, but I think this example can be used for any other settings library.
But providers.Confinguration has the from_pydantic method (and many other integration methods), for what? Should I use it instead of the Singleton provider?
I just want to know the best practice and would appreciate any explanation)
This code works pretty well:
I used pydantic settings, but I think this example can be used for any other settings library.
But
providers.Confinguration
has thefrom_pydantic
method (and many other integration methods), for what? Should I use it instead of theSingleton
provider? I just want to know the best practice and would appreciate any explanation)