Merge branch 'release/3.43.0' into master

This commit is contained in:
Roman Mogylatov 2020-09-09 23:36:33 -04:00
commit 0cddc4cf25
23 changed files with 5423 additions and 5532 deletions

View File

@ -143,7 +143,7 @@ Here comes the ``Dependency Injector``.
What does the Dependency Injector do? What does the Dependency Injector do?
------------------------------------- -------------------------------------
With the dependency injection pattern objects lose the responsibility of assembling the With the dependency injection pattern objects loose the responsibility of assembling the
dependencies. The ``Dependency Injector`` absorbs that responsibility. dependencies. The ``Dependency Injector`` absorbs that responsibility.
``Dependency Injector`` helps to assemble the objects. ``Dependency Injector`` helps to assemble the objects.

View File

@ -3,7 +3,7 @@ dependency_injector.ext.aiohttp
.. automodule:: dependency_injector.ext.aiohttp .. automodule:: dependency_injector.ext.aiohttp
:members: :members:
:special-members: :show-inheritance:
.. disqus:: .. disqus::

View File

@ -3,7 +3,7 @@ dependency_injector.containers
.. automodule:: dependency_injector.containers .. automodule:: dependency_injector.containers
:members: :members:
:special-members: :inherited-members:
:show-inheritance:
.. disqus:: .. disqus::

View File

@ -3,7 +3,7 @@ dependency_injector.ext.flask
.. automodule:: dependency_injector.ext.flask .. automodule:: dependency_injector.ext.flask
:members: :members:
:special-members: :show-inheritance:
.. disqus:: .. disqus::

View File

@ -78,6 +78,7 @@ Key features of the ``Dependency Injector``:
and dictionaries. See :ref:`configuration-provider`. and dictionaries. See :ref:`configuration-provider`.
- **Containers**. Provides declarative and dynamic containers. See :ref:`containers`. - **Containers**. Provides declarative and dynamic containers. See :ref:`containers`.
- **Performance**. Fast. Written in ``Cython``. - **Performance**. Fast. Written in ``Cython``.
- **Typing**. Provides typing stubs, ``mypy``-friendly.
- **Maturity**. Mature and production-ready. Well-tested, documented and supported. - **Maturity**. Mature and production-ready. Well-tested, documented and supported.
.. code-block:: python .. code-block:: python

View File

@ -123,7 +123,7 @@ Here comes the ``Dependency Injector``.
What does the Dependency Injector do? What does the Dependency Injector do?
------------------------------------- -------------------------------------
With the dependency injection pattern objects lose the responsibility of assembling the With the dependency injection pattern objects loose the responsibility of assembling the
dependencies. The ``Dependency Injector`` absorbs that responsibility. dependencies. The ``Dependency Injector`` absorbs that responsibility.
``Dependency Injector`` helps to assemble the objects. ``Dependency Injector`` helps to assemble the objects.
@ -178,7 +178,7 @@ client with a mock:
with container.api_client.override(mock.Mock()): with container.api_client.override(mock.Mock()):
service = container.service() service = container.service()
You can override any provider by another provider. You can override any provider with another provider.
It also helps you in configuring project for the different environments: replace an API client It also helps you in configuring project for the different environments: replace an API client
with a stub on the dev or stage. with a stub on the dev or stage.

View File

@ -31,7 +31,7 @@ Verification of currently installed version could be done using
>>> import dependency_injector >>> import dependency_injector
>>> dependency_injector.__version__ >>> dependency_injector.__version__
'3.38.0' '3.43.0'
.. _PyPi: https://pypi.org/project/dependency-injector/ .. _PyPi: https://pypi.org/project/dependency-injector/
.. _GitHub: https://github.com/ets-labs/python-dependency-injector .. _GitHub: https://github.com/ets-labs/python-dependency-injector

View File

@ -20,6 +20,7 @@ Key features of the ``Dependency Injector``:
and dictionaries. See :ref:`configuration-provider`. and dictionaries. See :ref:`configuration-provider`.
- **Containers**. Provides declarative and dynamic containers. See :ref:`containers`. - **Containers**. Provides declarative and dynamic containers. See :ref:`containers`.
- **Performance**. Fast. Written in ``Cython``. - **Performance**. Fast. Written in ``Cython``.
- **Typing**. Provides typing stubs, ``mypy``-friendly.
- **Maturity**. Mature and production-ready. Well-tested, documented and supported. - **Maturity**. Mature and production-ready. Well-tested, documented and supported.
The framework stands on two principles: The framework stands on two principles:

View File

@ -7,6 +7,12 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly From version 0.7.6 *Dependency Injector* framework strictly
follows `Semantic versioning`_ follows `Semantic versioning`_
3.43.0
------
- Update API documentation.
- Remove not relevant "speech" example.
- Fix a few typos.
3.42.0 3.42.0
------ ------
- Update "DI in Python" documentation page. - Update "DI in Python" documentation page.

View File

@ -24,7 +24,7 @@ It causes the cascade effect that helps to assemble object graphs. See ``Factory
└──> provider6() └──> provider6()
Another providers feature is an overriding. You can override any provider by another provider. Another providers feature is an overriding. You can override any provider with another provider.
This helps in testing. This also helps in overriding API clients with stubs for the development This helps in testing. This also helps in overriding API clients with stubs for the development
or staging environment. See the example at :ref:`provider-overriding`. or staging environment. See the example at :ref:`provider-overriding`.

View File

@ -10,7 +10,7 @@ Provider overriding
.. currentmodule:: dependency_injector.providers .. currentmodule:: dependency_injector.providers
You can override any provider by another provider. You can override any provider with another provider.
When provider is overridden it calls to the overriding provider instead of providing When provider is overridden it calls to the overriding provider instead of providing
the object by its own. the object by its own.

View File

@ -1,26 +0,0 @@
"""IoC container example."""
import collections
import dependency_injector.containers as containers
import dependency_injector.providers as providers
Engine = collections.namedtuple('Engine', [])
Car = collections.namedtuple('Car', ['serial_number', 'engine'])
class Container(containers.DeclarativeContainer):
"""IoC container."""
engine_factory = providers.Factory(Engine)
car_factory = providers.Factory(Car, engine=engine_factory)
if __name__ == '__main__':
car1 = Container.car_factory(serial_number=1)
car2 = Container.car_factory(serial_number=2)
assert car1.serial_number == 1 and car2.serial_number == 2
assert car1.engine is not car2.engine

View File

@ -1,14 +0,0 @@
"""Factory provider example."""
from dependency_injector import providers
object_factory = providers.Factory(object)
if __name__ == '__main__':
object1 = object_factory()
object2 = object_factory()
assert object1 is not object2
assert isinstance(object1, object) and isinstance(object2, object)

View File

@ -1,20 +0,0 @@
"""Factory provider keyword argument injections example."""
import collections
import dependency_injector.providers as providers
Engine = collections.namedtuple('Engine', [])
Car = collections.namedtuple('Car', ['serial_number', 'engine'])
engine_factory = providers.Factory(Engine)
car_factory = providers.Factory(Car, engine=engine_factory)
if __name__ == '__main__':
car1 = car_factory(serial_number=1)
car2 = car_factory(serial_number=2)
assert car1.serial_number == 1 and car2.serial_number == 2
assert car1.engine is not car2.engine

View File

@ -1,24 +0,0 @@
"""Overriding of factory provider example."""
import collections
import dependency_injector.providers as providers
Engine = collections.namedtuple('Engine', [])
Car = collections.namedtuple('Car', ['serial_number', 'engine'])
engine_factory = providers.Factory(Engine)
car_factory = providers.Factory(Car, engine=engine_factory)
EngineX = collections.namedtuple('EngineX', [])
engine_factory.override(providers.Factory(EngineX))
if __name__ == '__main__':
car1 = car_factory(serial_number=1)
car2 = car_factory(serial_number=2, engine=Engine())
assert car1.serial_number == 1 and car2.serial_number == 2
assert car1.engine.__class__ is EngineX
assert car2.engine.__class__ is Engine

View File

@ -1,21 +0,0 @@
"""@inject decorator example."""
from container import Container
from dependency_injector.injections import inject
@inject(car_factory=Container.car_factory.delegate())
@inject(extra_engine=Container.engine_factory)
def main(car_factory, extra_engine):
"""Run application."""
car1 = car_factory(serial_number=1)
car2 = car_factory(serial_number=2, engine=extra_engine)
assert car1.serial_number == 1 and car2.serial_number == 2
assert car1.engine is not car2.engine
assert car2.engine is extra_engine
if __name__ == '__main__':
main()

View File

@ -1,7 +1,7 @@
"""Dependency injector top-level package.""" """Top-level package."""
__version__ = '3.42.0' __version__ = '3.43.0'
"""Version number that follows semantic versioning. """Version number.
:type: str :type: str
""" """

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,4 @@
"""Dependency injector containers. """Containers module."""
Powered by Cython.
"""
# Declarative containers are declared as regular types because of metaclasses # Declarative containers are declared as regular types because of metaclasses

View File

@ -1,7 +1,4 @@
"""Dependency injector containers. """Containers module."""
Powered by Cython.
"""
import six import six

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,4 @@
"""Dependency injector providers. """Providers module."""
Powered by Cython.
"""
cimport cython cimport cython

View File

@ -1,7 +1,4 @@
"""Dependency injector providers. """Providers module."""
Powered by Cython.
"""
from __future__ import absolute_import from __future__ import absolute_import