Skip to main content

Constructor injection designed with OOP in mind.

Project description

Dependencies build pypi

Constructor injection designed with OOP in mind.

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.

Enterprise support

If you have an issue with any version of the library, you can apply for a paid enterprise support contract. This will guarantee you that no breaking changes will happen to you. No matter how old version you're using at the moment. All necessary features and bug fixes will be backported in a way that serves your needs.

Please contact proofit404@gmail.com if you're interested in it.

License

dependencies library is offered under the two clause BSD license.

— ⭐ —

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dependencies-8.0.0rc1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dependencies-8.0.0rc1-py2.py3-none-any.whl (15.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file dependencies-8.0.0rc1.tar.gz.

File metadata

  • Download URL: dependencies-8.0.0rc1.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.4 Linux/5.15.0-1022-azure

File hashes

Hashes for dependencies-8.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 dba8009aa6f0fe0bfd00edb367a7542d8387c96073cf304c23a0999e42b707f8
MD5 2ca66bb0042de6d536eee56724856132
BLAKE2b-256 f9e92eff1689f016724d0518881e499a2a8091cef68f450376cd446026fe57c0

See more details on using hashes here.

File details

Details for the file dependencies-8.0.0rc1-py2.py3-none-any.whl.

File metadata

  • Download URL: dependencies-8.0.0rc1-py2.py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.4 Linux/5.15.0-1022-azure

File hashes

Hashes for dependencies-8.0.0rc1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1b1bc3f749a5d827b50a0d7cdef58d90af46f3fe02e111d906a922a26ea42380
MD5 5b6789b2af15f5fd04572901c83dd2ee
BLAKE2b-256 8863a522abd0d7f0a0d604f94bb88ce2a75b7608ec8149485e44b5663d58ff4b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page