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.dev2.tar.gz
(5.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file junkie-3.0.0.dev2.tar.gz.
File metadata
- Download URL: junkie-3.0.0.dev2.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c8734296867f8e204171a60b0e1fc33a2b9973d6641cc378a5a3366a4dadf3d
|
|
| MD5 |
ac5f38a7c6f28922e94c9faedc101009
|
|
| BLAKE2b-256 |
1be4038cab6372b85596af09643147fbf01bd581dfbc3a27671df610a7786261
|
File details
Details for the file junkie-3.0.0.dev2-py3-none-any.whl.
File metadata
- Download URL: junkie-3.0.0.dev2-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58a713bff33794bf489c7751fdd85624c9a51f0ec47e9474d099baf7d5e34d5a
|
|
| MD5 |
1b2c8f8ededbedb8d286eb83a92ff662
|
|
| BLAKE2b-256 |
5f4948a8f5f4f5bfeeec31a8e360e6fd72a6ea076732ac8b4812bc381832e0c5
|