Skip to main content

Simple and flexible dependency injection framework.

Project description

Azure Pipelines PyPI - Package version PyPI - Python Version https://codecov.io/gh/elfjes/gimme-that/branch/master/graph/badge.svg Read the Docs

Gimme That

A lightweight, simple but extensible dependency injection framework. Read the full documentation here

Getting started

Install from PyPI

pip install gimme-that

Basic usage

import gimme


class MyService:
    pass


class ServiceConsumer:
    def __init__(self, service: MyService):
        self.service = service


# gimme.that automatically detects and resolves dependencies based on type annotations
consumer = gimme.that(ServiceConsumer)

isinstance(consumer.service, MyService)  # True

Features

  • Automatically detects dependencies based on type annotations
  • Works with dataclass classes and attr.s
  • Class repository that stores created objects for re-use
  • Register classes to provide additional configuration on how gimme.that should instantiate classes
    • Custom factory functions
    • Store or do not store created objects
    • Provide additional keyword arguments to the initializer
  • Scoped repositories to manage the lifetime of created objects (useful for testing)
  • Does not require any decorators or other additions to your classes (most of the time). They remain your classes
  • Detects circular dependencies, and provides the means to resolve them
  • Extensibility using plugins: create your own logic for resolving dependencies and instantiating classes

Development

pip install -e .[dev]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gimme-that, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size gimme_that-0.1.3-py3-none-any.whl (10.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size gimme-that-0.1.3.tar.gz (10.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page