Skip to main content

No project description provided

Project description

# dependency injection

A dependency injection framework for python.

Just like `Microsoft.Extensions.DependencyInjection`.

## Usage

``` py
class A:
pass

class B:
def __init__(self, a: A):
assert isinstance(a, A)

import dependencyinjection as di

service = di.Services()
service.scoped(A)
service.singleton(B)
provider = service.build()
assert isinstance(provider.get(A), A)
assert isinstance(provider.get(B), B)

with provider.scope() as scoped_provider:
assert provider.get(A) is provider.get(A)
assert scoped_provider.get(B) is scoped_provider.get(B)
assert provider.get(B) is scoped_provider.get(B)
assert not (provider.get(A) is scoped_provider.get(A))
```

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

dependencyinjection-0.1.2.0.tar.gz (6.2 kB view hashes)

Uploaded Source

Built Distribution

dependencyinjection-0.1.2.0-py3.6.egg (29.0 kB view hashes)

Uploaded Source

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