mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
Merge branch 'release/3.30.2' into master
This commit is contained in:
commit
88866d596b
54
README.rst
54
README.rst
|
@ -52,7 +52,59 @@ What is ``Dependency Injector``?
|
||||||
|
|
||||||
``Dependency Injector`` is a dependency injection framework for Python.
|
``Dependency Injector`` is a dependency injection framework for Python.
|
||||||
|
|
||||||
It provides you with the container and the providers that help you build your application objects:
|
It helps you implement the dependency injection principle.
|
||||||
|
|
||||||
|
What is dependency injection?
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Dependency injection is a principle that helps to decrease coupling and increase cohesion. Your
|
||||||
|
code becomes more flexible, clear and it is easier to test it.
|
||||||
|
|
||||||
|
How to implement dependency injection?
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
|
Objects do not create each other anymore. They provide a way to inject the needed dependency
|
||||||
|
instead.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
class ApiClient:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.api_key = os.getenv('API_KEY')
|
||||||
|
self.timeout = os.getenv('TIMEOUT')
|
||||||
|
|
||||||
|
|
||||||
|
class Service:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.api_client = ApiClient()
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
class ApiClient:
|
||||||
|
|
||||||
|
def __init__(self, api_key: str, timeout: int):
|
||||||
|
self.api_key = api_key
|
||||||
|
self.timeout = timeout
|
||||||
|
|
||||||
|
|
||||||
|
class Service:
|
||||||
|
|
||||||
|
def __init__(self, api_client: ApiClient):
|
||||||
|
self.api_client = api_client
|
||||||
|
|
||||||
|
Who creates the objects now? Look at the next section.
|
||||||
|
|
||||||
|
What does Dependency Injector do?
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
``Dependency Injector`` provides you with the container and the providers that help you build
|
||||||
|
your application objects when you apply dependency injection principle:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@ 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.30.2
|
||||||
|
------
|
||||||
|
- Update README.
|
||||||
|
|
||||||
3.30.1
|
3.30.1
|
||||||
------
|
------
|
||||||
- Update README.
|
- Update README.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Dependency injector top-level package."""
|
"""Dependency injector top-level package."""
|
||||||
|
|
||||||
__version__ = '3.30.1'
|
__version__ = '3.30.2'
|
||||||
"""Version number that follows semantic versioning.
|
"""Version number that follows semantic versioning.
|
||||||
|
|
||||||
:type: str
|
:type: str
|
||||||
|
|
Loading…
Reference in New Issue
Block a user