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 Context
class App:
def __init__(self, text: str):
self.text = text
def greets(self) -> str:
return self.text
context = Context({
"greeting": "Hello",
"name": "Joe",
"text": lambda greeting, name: f"{greeting} {name}!"
})
with context.build(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.dev1.tar.gz
(5.1 kB
view hashes)
Built Distribution
Close
Hashes for junkie-3.0.0.dev1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21619843bbd2ad490b854ca30269af9b12fb64c2691a5096ec819168dc3f436e |
|
MD5 | a88c0610b7bf823ff5b39c3c72a72cb0 |
|
BLAKE2b-256 | e4206f6360cb8dc5097b03e8973cede0272b23d1e87d0d176a958abf7e57df68 |