Overview¶
Smart-injector is an lightweight dependency injection framework for Python. It was designed to be an easy to use tool to implement dependency injection in your application in a pythonic way.
Key features are: - Ligtweight - pure python - leverages type annotations - scopes - non invasive
Project Status¶
docs | |
---|---|
tests | |
package |
Installation¶
pip install smart-injector
You can also install the in-development version with:
pip install https://github.com/hlevering/python-smart-injector/archive/master.zip
Quickstart¶
Basic Usage:
>>> class A:
... pass
...
>>> class B:
... def __init__(self, a: A):
... self.a = a
...
>>> container = create_container(StaticContainer)
>>> b = container.get(B)
>>> isinstance(b.a, A)
True
Documentation¶
Detailed documentation can be found here:
https://python-smart-injector.readthedocs.io/
Further usage examples can be found here: https://python-smart-injector.readthedocs.io/en/latest/usage.html
Development¶
To run the all tests run:
tox
Note, to combine the coverage data from all the tox environments run:
Windows | set PYTEST_ADDOPTS=--cov-append
tox
|
---|---|
Other | PYTEST_ADDOPTS=--cov-append tox
|