Dependencies
Dependency Injection for Humans.
Documentation | Source Code | Task Tracker
Dependency Injection (or simply DI) is a great technique. By using it you can organize responsibilities in you codebase. Define high level policies and system behavior in one part. Delegate control to low level mechanisms in another part. Simple and powerful.
With help of DI you can use different parts of your system independently and combine their behavior really easy.
If you split logic and implementation into different classes, you will see how pleasant it becomes to change your system.
This tiny library helps you to connect parts of your system, in particular - to inject low level implementation into high level behavior.
Pros
- Provide composition instead of inheritance.
- Solves top-down architecture problems.
- Boilerplate-free object hierarchies.
- API entrypoints, admin panels, CLI commands are oneliners.
Example
Dependency injection without dependencies
>>> from app.robot import Robot, Servo, Amplifier, Controller, Settings
>>> robot = Robot(
... servo=Servo(amplifier=Amplifier()),
... controller=Controller(),
... settings=Settings(environment="production"),
... )
>>> robot.work()
Dependency injection with dependencies
>>> from dependencies import Injector
>>> class Container(Injector):
... robot = Robot
... servo = Servo
... amplifier = Amplifier
... controller = Controller
... settings = Settings
... environment = "production"
>>> Container.robot.work()
Questions
If you have any questions, feel free to create an issue in our Task Tracker. We have the question label exactly for this purpose.
License
Dependencies library is offered under the two clause BSD license.
— ⭐️ —
The dependencies library is part of the SOLID python family.
Metadata
Release files for dependencies 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dependencies-2.0.1.tar.gz | 10.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dependencies-2.0.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 25.6 kB
Release files / dependencies-2.0.1.tar.gz
| Download URL | dependencies-2.0.1.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89f8262059ee6fb7a27f12bc72cec41e4a954a7b6f5ba0b4c902be1495e1cd12
|
|
BLAKE2b-256 checksum How to use checksums |
cbc88d296cc25e199183233f7eb79d8bd80598484491b7200d0a5407af285000
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.9 CPython/3.8.3 Linux/4.15.0-1091-azure
|
Release files / dependencies-2.0.1-py2.py3-none-any.whl
| Download URL | dependencies-2.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
4f2acdafd3f17f20b717e0691f5652d01bb1099f9d851926e7d2913bff299c61
|
|
BLAKE2b-256 checksum How to use checksums |
a6b7d07e44c49429eba1c2eeffbde551a9ea3838c5ab34fafd544999fd4f925e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.9 CPython/3.8.3 Linux/4.15.0-1091-azure
|
Security for dependencies 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.