@@ -48,34 +48,34 @@ What is ``Dependency Injector``?
48
48
49
49
``Dependency Injector `` is a dependency injection framework for Python.
50
50
51
- It helps implementing the dependency injection principle.
51
+ It helps implement the dependency injection principle.
52
52
53
53
Key features of the ``Dependency Injector ``:
54
54
55
55
- **Providers **. Provides ``Factory ``, ``Singleton ``, ``Callable ``, ``Coroutine ``, ``Object ``,
56
- ``List ``, ``Dict ``, ``Configuration ``, ``Resource ``, ``Dependency `` and ``Selector `` providers
57
- that help assembling your objects.
56
+ ``List ``, ``Dict ``, ``Configuration ``, ``Resource ``, ``Dependency ``, and ``Selector `` providers
57
+ that help assemble your objects.
58
58
See `Providers <https://python-dependency-injector.ets-labs.org/providers/index.html >`_.
59
59
- **Overriding **. Can override any provider by another provider on the fly. This helps in testing
60
- and configuring dev / stage environment to replace API clients with stubs etc. See
60
+ and configuring dev/ stage environment to replace API clients with stubs etc. See
61
61
`Provider overriding <https://python-dependency-injector.ets-labs.org/providers/overriding.html >`_.
62
- - **Configuration **. Reads configuration from ``yaml `` & ``ini `` files, ``pydantic `` settings,
62
+ - **Configuration **. Reads configuration from ``yaml ``, ``ini ``, and `` json `` files, ``pydantic `` settings,
63
63
environment variables, and dictionaries.
64
64
See `Configuration provider <https://python-dependency-injector.ets-labs.org/providers/configuration.html >`_.
65
- - **Containers **. Provides declarative and dynamic containers.
66
- See `Containers <https://python-dependency-injector.ets-labs.org/containers/index.html >`_.
67
65
- **Resources **. Helps with initialization and configuring of logging, event loop, thread
68
66
or process pool, etc. Can be used for per-function execution scope in tandem with wiring.
69
67
See `Resource provider <https://python-dependency-injector.ets-labs.org/providers/resource.html >`_.
70
- - **Wiring **. Injects dependencies into functions and methods. Helps integrating with
68
+ - **Containers **. Provides declarative and dynamic containers.
69
+ See `Containers <https://python-dependency-injector.ets-labs.org/containers/index.html >`_.
70
+ - **Wiring **. Injects dependencies into functions and methods. Helps integrate with
71
71
other frameworks: Django, Flask, Aiohttp, Sanic, FastAPI, etc.
72
72
See `Wiring <https://python-dependency-injector.ets-labs.org/wiring.html >`_.
73
73
- **Asynchronous **. Supports asynchronous injections.
74
74
See `Asynchronous injections <https://python-dependency-injector.ets-labs.org/providers/async.html >`_.
75
75
- **Typing **. Provides typing stubs, ``mypy ``-friendly.
76
76
See `Typing and mypy <https://python-dependency-injector.ets-labs.org/providers/typing_mypy.html >`_.
77
77
- **Performance **. Fast. Written in ``Cython ``.
78
- - **Maturity **. Mature and production-ready. Well-tested, documented and supported.
78
+ - **Maturity **. Mature and production-ready. Well-tested, documented, and supported.
79
79
80
80
.. code-block :: python
81
81
@@ -100,7 +100,7 @@ Key features of the ``Dependency Injector``:
100
100
101
101
102
102
@inject
103
- def main (service : Service = Provide[Container.service]):
103
+ def main (service : Service = Provide[Container.service]) -> None :
104
104
...
105
105
106
106
@@ -115,19 +115,18 @@ Key features of the ``Dependency Injector``:
115
115
with container.api_client.override(mock.Mock()):
116
116
main() # <-- overridden dependency is injected automatically
117
117
118
- When you call ``main() `` function the ``Service `` dependency is assembled and injected automatically.
118
+ When you call the ``main() `` function the ``Service `` dependency is assembled and injected automatically.
119
119
120
- When doing a testing you call the ``container.api_client.override() `` to replace the real API
121
- client with a mock. When you call ``main() `` the mock is injected.
120
+ When you do testing, you call the ``container.api_client.override() `` method to replace the real API
121
+ client with a mock. When you call ``main() ``, the mock is injected.
122
122
123
123
You can override any provider with another provider.
124
124
125
- It also helps you in configuring project for the different environments: replace an API client
125
+ It also helps you in a re- configuring project for different environments: replace an API client
126
126
with a stub on the dev or stage.
127
127
128
- With the ``Dependency Injector `` objects assembling is consolidated in the container.
129
- Dependency injections are defined explicitly.
130
- This makes easier to understand and change how application works.
128
+ With the ``Dependency Injector ``, object assembling is consolidated in a container. Dependency injections are defined explicitly.
129
+ This makes it easier to understand and change how an application works.
131
130
132
131
.. figure :: https://raw.githubusercontent.com/wiki/ets-labs/python-dependency-injector/img/di-readme.svg
133
132
:target: https://github.com/ets-labs/python-dependency-injector
@@ -185,27 +184,27 @@ The framework stands on the `PEP20 (The Zen of Python) <https://www.python.org/d
185
184
186
185
You need to specify how to assemble and where to inject the dependencies explicitly.
187
186
188
- The power of the framework is in a simplicity.
187
+ The power of the framework is in its simplicity.
189
188
``Dependency Injector `` is a simple tool for the powerful concept.
190
189
191
190
Frequently asked questions
192
191
--------------------------
193
192
194
- What is the dependency injection?
193
+ What is dependency injection?
195
194
- dependency injection is a principle that decreases coupling and increases cohesion
196
195
197
196
Why should I do the dependency injection?
198
197
- your code becomes more flexible, testable, and clear 😎
199
198
200
- How do I start doing the dependency injection?
199
+ How do I start applying the dependency injection?
201
200
- you start writing the code following the dependency injection principle
202
201
- you register all of your application components and their dependencies in the container
203
202
- when you need a component, you specify where to inject it or get it from the container
204
203
205
204
What price do I pay and what do I get?
206
205
- you need to explicitly specify the dependencies
207
- - it will be an extra work in the beginning
208
- - it will payoff as the project grows
206
+ - it will be extra work in the beginning
207
+ - it will payoff as project grows
209
208
210
209
Have a question?
211
210
- Open a `Github Issue <https://github.com/ets-labs/python-dependency-injector/issues >`_
0 commit comments