2020-09-02 04:39:23 +03:00
|
|
|
Dependency provider
|
2020-09-03 00:33:02 +03:00
|
|
|
===================
|
2015-06-18 16:34:26 +03:00
|
|
|
|
2015-11-30 00:30:48 +03:00
|
|
|
.. currentmodule:: dependency_injector.providers
|
2015-11-23 17:48:21 +03:00
|
|
|
|
2020-09-02 04:39:23 +03:00
|
|
|
:py:class:`Dependency` provider is a placeholder for the dependency of the specified type.
|
2015-06-18 16:34:26 +03:00
|
|
|
|
2020-09-02 04:39:23 +03:00
|
|
|
The first argument of the ``Dependency`` provider specifies a type of the dependency. It is
|
|
|
|
called ``instance_of``. ``Dependency`` provider controls the type of the returned object to be an
|
|
|
|
instance of the ``instance_of`` type.
|
2015-06-18 16:34:26 +03:00
|
|
|
|
2020-09-02 04:39:23 +03:00
|
|
|
The ``Dependency`` provider must be overridden before usage. It can be overridden by any type of
|
|
|
|
the provider. The only rule is that overriding provider must return an instance of ``instance_of``
|
|
|
|
dependency type.
|
2015-06-18 16:34:26 +03:00
|
|
|
|
2017-12-21 23:54:44 +03:00
|
|
|
.. literalinclude:: ../../examples/providers/dependency.py
|
2015-08-03 15:45:58 +03:00
|
|
|
:language: python
|
2020-09-02 04:39:23 +03:00
|
|
|
:lines: 3-
|
|
|
|
:emphasize-lines: 26
|
2017-02-28 23:07:12 +03:00
|
|
|
|
|
|
|
.. disqus::
|