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.0.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

dependencyinjection-0.1.0.1-py3.6.egg (25.0 kB view details)

Uploaded Source

File details

Details for the file dependencyinjection-0.1.0.1.tar.gz.

File metadata

File hashes

Hashes for dependencyinjection-0.1.0.1.tar.gz
Algorithm Hash digest
SHA256 cfbecddec5987ec9de9427951c2936000a0ca259b3fed30ececd5c187c4ff9a8
MD5 bdf86a1fca4da6bf74f75828e3cf7c93
BLAKE2b-256 10f1a6df37bb6c8a39b25fc8dfe3a6df890f33ac8140c455ec377cf1a7100c3b

See more details on using hashes here.

File details

Details for the file dependencyinjection-0.1.0.1-py3.6.egg.

File metadata

File hashes

Hashes for dependencyinjection-0.1.0.1-py3.6.egg
Algorithm Hash digest
SHA256 ecea437f77cc501c030c2cb3e4dfa33e2d6fd568e403fa553da6d48cc88b085b
MD5 71de780a4a717b5b3c16f90976379185
BLAKE2b-256 9703174a5692f2a292cb1b0107c0d3a6b9acd0916b25a095feb3b28840e013a5

See more details on using hashes here.

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