Skip to main content

A simple dependency injector for Python

Project description

dinjector

A simple dependency injector for Python.

Installation

You can install the package using pip:

pip install dinjector

Usage
Here's an example of how to use dinjector:

```python
from dinjector.injector import Injector, inject

class Service:
    def __init__(self, config):
        self.config = config

class Config:
    pass

Injector.register(Service, config=Config())

class Client:
    @inject
    def __init__(self, service: Service):
        self.service = service

client = Client()
print(client.service)  # Instance of Service with injected Config

Project details


Download files

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

Source Distribution

dinjectorr-0.1.0.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

dinjectorr-0.1.0-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

Supported by

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