You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://github.com/runemalm/py-dependency-injection/actions/workflows/master.yml)
3
4
4
-
##py-dependency-injection
5
+
# py-dependency-injection
5
6
6
-
This is a simple and lightweight dependency injection library for python.
7
+
A dependency injection library for Python.
7
8
8
-
###Features:
9
+
## Features:
9
10
10
11
- Dependency Container
11
12
- Dependency Scopes
12
13
- Constructor Injection
13
14
- Method Injection
14
15
15
-
### Python Compatibility
16
-
17
-
This library is compatible and tested with the following Python versions:
16
+
## Python Compatibility
18
17
19
-
- Python 3.7
20
-
- Python 3.8
21
-
- Python 3.9
22
-
- Python 3.10
23
-
- Python 3.11
24
-
- Python 3.12
18
+
This library is compatible with the following Python versions:
25
19
26
-
[](https://github.com/runemalm/py-dependency-injection/actions/workflows/master.yml)
20
+
- 3.7, 3.8, 3.9, 3.10, 3.11, 3.12
27
21
28
-
###Installation:
22
+
## Installation:
29
23
30
24
```bash
31
25
$ pip install py-dependency-injection
32
26
```
33
-
34
-
### Example - Getting a dependency container:
27
+
28
+
## Usage:
29
+
30
+
### Example: Obtaining the Default Dependency Container
35
31
36
32
```python
37
-
# While you can create multiple containers, it's typically recommended to use one per application.
38
-
# For this purpose, you can easily obtain the default container.
33
+
# Retrieve the default container, typically recommended for a single-application setup.
39
34
40
35
from dependency_injection.container import DependencyContainer
# As long as the class is resolved using the dependency container,
79
-
# dependencies are injected into it's constructor at resolution time.
78
+
# Class instances resolved through the container have dependencies injected into their constructors.
80
79
81
80
classFoo:
82
81
@@ -86,12 +85,12 @@ class Foo:
86
85
self._singleton_instance = singleton_instance
87
86
```
88
87
89
-
### Example - Method injection:
88
+
### Example: Method Injection
90
89
91
90
```python
92
-
#Dependencies can be injected into an instance method using the `@inject` decorator.
93
-
#The dependency container and scope name can be provided as arguments to the decorator.
94
-
# If none are provided, the default container and scope are applied.
91
+
#Inject dependencies into instance methods using the `@inject` decorator.
92
+
#You may pass 'container_name' and 'scope_name' as decorator arguments.
93
+
95
94
from dependency_injection.decorator import inject
96
95
97
96
@@ -104,25 +103,24 @@ class Foo:
104
103
singleton_instance.do_something()
105
104
```
106
105
107
-
###Documentation:
106
+
## Documentation:
108
107
109
-
You can find the latest documentation at[readthedocs](https://py-dependency-injection.readthedocs.io/en/latest/).
108
+
For the latest documentation, visit[readthedocs](https://py-dependency-injection.readthedocs.io/en/latest/).
110
109
111
-
### Contribution:
112
-
113
-
If you want to contribute to the code base, create a pull request on the develop branch.
110
+
## Contribution:
114
111
115
-
We follow the [git flow](https://nvie.com/posts/a-successful-git-branching-model/) branching model.
112
+
To contribute, create a pull request on the develop branch following the [git flow](https://nvie.com/posts/a-successful-git-branching-model/) branching model.
- Python Version Support: Added support for Python versions 3.7, 3.9, 3.10, 3.11, and 3.12.
122
119
- New Feature: Method Injection with Decorator: Introduced a new feature allowing method injection using the @inject decorator. Dependencies can now be injected into an instance method, providing more flexibility in managing dependencies within class instance methods.
120
+
- New Feature: Multiple Containers: Enhanced the library to support multiple containers. Users can now create and manage multiple dependency containers, enabling better organization and separation of dependencies for different components or modules.
123
121
- Documentation Update: Expanded and improved the documentation to include details about the newly added method injection feature and additional usage examples. Users can refer to the latest documentation at readthedocs for comprehensive guidance.
Copy file name to clipboardExpand all lines: docs/versionhistory.rst
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,11 @@
2
2
Version history
3
3
###############
4
4
5
-
**1.0.0-alpha.2 (2024-02-xx)**
5
+
**1.0.0-alpha.2 (2024-02-27)**
6
6
7
7
- Python Version Support: Added support for Python versions 3.7, 3.9, 3.10, 3.11, and 3.12.
8
8
- New Feature: Method Injection with Decorator: Introduced a new feature allowing method injection using the @inject decorator. Dependencies can now be injected into an instance method, providing more flexibility in managing dependencies within class instance methods.
9
+
- New Feature: Multiple Containers: Enhanced the library to support multiple containers. Users can now create and manage multiple dependency containers, enabling better organization and separation of dependencies for different components or modules.
9
10
- Documentation Update: Expanded and improved the documentation to include details about the newly added method injection feature and additional usage examples. Users can refer to the latest documentation at readthedocs for comprehensive guidance.
10
11
11
12
`View release on GitHub <https://github.com/runemalm/py-dependency-injection/releases/tag/v1.0.0-alpha.2>`_
0 commit comments