From e38eb618beede7332cfbb707d26fa353d3901737 Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Tue, 26 Oct 2021 21:03:32 -0400 Subject: [PATCH] Add docs --- docs/providers/configuration.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/providers/configuration.rst b/docs/providers/configuration.rst index ddacdd72..dc59a538 100644 --- a/docs/providers/configuration.rst +++ b/docs/providers/configuration.rst @@ -154,6 +154,21 @@ If you need to pass an argument to this call, use ``.from_pydantic()`` keyword a container.config.from_pydantic(Settings(), exclude={"optional"}) +Alternatively, you can provide a ``pydantic`` settings object over the configuration provider argument. In that case, +the container will call ``config.from_pydantic()`` automatically: + +.. code-block:: python + :emphasize-lines: 3 + + class Container(containers.DeclarativeContainer): + + config = providers.Configuration(pydantic_settings=[Settings()]) + + + if __name__ == "__main__": + container = Container() # Config is loaded from Settings() + + .. note:: ``Dependency Injector`` doesn't install ``pydantic`` by default.