python-dependency-injector
python-dependency-injector copied to clipboard
Docs Example loading-from-a-pydantic-settings is wrong
https://python-dependency-injector.ets-labs.org/providers/configuration.html#loading-from-a-pydantic-settings
In the docs, i have read this:
To get the data from pydantic settings Configuration provider calls Settings.dict() method. If you need to pass an argument to this call, use .from_pydantic() keyword arguments.
class Settings(BaseSettings):
aws: AwsSettings = AwsSettings()
optional: str = Field(default="default_value")
class Container(containers.DeclarativeContainer):
config = providers.Configuration()
container = Container()
container.config.from_pydantic(Settings())
assert container.config.aws.access_key_id() == "KEY"
so container.config is a dict, and cannot access aws attribute.