@@ -183,22 +183,22 @@ See also: :ref:`configuration-envs-interpolation`.
183183Loading from a Pydantic settings
184184--------------------------------
185185
186- ``Configuration `` provider can load configuration from a ``pydantic `` settings object using the
186+ ``Configuration `` provider can load configuration from a ``pydantic_settings.BaseSettings `` object using the
187187:py:meth: `Configuration.from_pydantic ` method:
188188
189189.. literalinclude :: ../../examples/providers/configuration/configuration_pydantic.py
190190 :language: python
191191 :lines: 3-
192- :emphasize-lines: 31
192+ :emphasize-lines: 32
193193
194- To get the data from pydantic settings ``Configuration `` provider calls `` Settings.dict () `` method.
194+ To get the data from pydantic settings ``Configuration `` provider calls its `` model_dump () `` method.
195195If you need to pass an argument to this call, use ``.from_pydantic() `` keyword arguments.
196196
197197.. code-block :: python
198198
199199 container.config.from_pydantic(Settings(), exclude = {" optional" })
200200
201- Alternatively, you can provide a ``pydantic `` settings object over the configuration provider argument. In that case,
201+ Alternatively, you can provide a ``pydantic_settings.BaseSettings `` object over the configuration provider argument. In that case,
202202the container will call ``config.from_pydantic() `` automatically:
203203
204204.. code-block :: python
@@ -215,18 +215,23 @@ the container will call ``config.from_pydantic()`` automatically:
215215
216216 .. note ::
217217
218- ``Dependency Injector `` doesn't install ``pydantic `` by default.
218+ ``Dependency Injector `` doesn't install ``pydantic-settings `` by default.
219219
220220 You can install the ``Dependency Injector `` with an extra dependency::
221221
222- pip install dependency-injector[pydantic ]
222+ pip install dependency-injector[pydantic2 ]
223223
224- or install ``pydantic `` directly::
224+ or install ``pydantic-settings `` directly::
225225
226- pip install pydantic
226+ pip install pydantic-settings
227227
228228 *Don't forget to mirror the changes in the requirements file. *
229229
230+ .. note ::
231+
232+ For backward-compatibility, Pydantic v1 is still supported.
233+ Passing ``pydantic.BaseSettings `` instances will work just as fine as ``pydantic_settings.BaseSettings ``.
234+
230235Loading from a dictionary
231236-------------------------
232237
0 commit comments