A dependency injection library for beginners
Project description
junkie
Junkie is a dependency injection library for beginners. It is easy to use and has no magic hidden state.
Core features:
- injects instances via parameter name and if not available via type annotation
- handles context managers when creating objects
- provides simple configuration with dictionaries
- can be easily combined with any other object instantiation approach
- supports a flexible way to define scopes
Example:
from junkie import Junkie
class App:
def __init__(self, text: str):
self.text = text
def greets(self) -> str:
return self.text
context = Junkie({
"greeting": "Hello",
"name": "Joe",
"text": lambda greeting, name: f"{greeting} {name}!"
})
with context.inject(App) as app:
assert app.greets() == "Hello Joe!"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
junkie-3.0.0.dev4.tar.gz
(7.4 kB
view hashes)
Built Distribution
Close
Hashes for junkie-3.0.0.dev4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6c3a3f8ca9b0f8c620595bd2ffee59d4ab7c7bcbdab0a2b9bb32de80bc40869 |
|
MD5 | 51c7687d178dfa79c8116ce184d75278 |
|
BLAKE2b-256 | 874e146cb327504abffdbf3dddc63f927e8380175819c47214c2e0a382bb4459 |