Skip to main content

Dependencies

azure-devops-builds azure-devops-coverage pypi conda

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.

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)

Source distribution for dependencies 2.0.1
File Size Uploaded
dependencies-2.0.1.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dependencies 2.0.1
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

7.7.1

2 release files

7.7.0

2 release files

7.6.0

2 release files

7.5.0

2 release files

7.4.0

2 release files

7.3.0

2 release files

7.2.0

2 release files

7.1.7

2 release files

7.1.6

2 release files

7.1.5

2 release files

7.1.4

2 release files

7.1.3

2 release files

7.1.2

2 release files

7.1.1

2 release files

7.1.0

2 release files

7.0.0

2 release files

6.0.1

2 release files

6.0.0

2 release files

5.2.0

2 release files

5.0.0

2 release files

4.1.0

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.0.0

2 release files

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.15

3 release files

0.14

3 release files

0.13

3 release files

0.12

3 release files

0.11

3 release files

0.10

3 release files

0.9

3 release files

0.8

3 release files

0.7

3 release files

0.6

3 release files

0.5

3 release files

0.4

3 release files

0.3

3 release files

0.2

3 release files

0.1

2 release files

0.1.dev1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page