Skip to content

Commit e38eb61

Browse files
committed
Add docs
1 parent ddf106f commit e38eb61

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/providers/configuration.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@ If you need to pass an argument to this call, use ``.from_pydantic()`` keyword a
154154
155155
container.config.from_pydantic(Settings(), exclude={"optional"})
156156
157+
Alternatively, you can provide a ``pydantic`` settings object over the configuration provider argument. In that case,
158+
the container will call ``config.from_pydantic()`` automatically:
159+
160+
.. code-block:: python
161+
:emphasize-lines: 3
162+
163+
class Container(containers.DeclarativeContainer):
164+
165+
config = providers.Configuration(pydantic_settings=[Settings()])
166+
167+
168+
if __name__ == "__main__":
169+
container = Container() # Config is loaded from Settings()
170+
171+
157172
.. note::
158173

159174
``Dependency Injector`` doesn't install ``pydantic`` by default.

0 commit comments

Comments
 (0)