Skip to main content

A dependency injection library for beginners

Project description


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


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 as app:
    assert app.greets() == "Hello Joe!"

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

junkie-2.0.0.tar.gz (4.3 kB view hashes)

Uploaded source

Built Distribution

junkie-2.0.0-py3-none-any.whl (6.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page