Skip to main content

Simple and flexible dependency injection framework.

Project description

Github Actions 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.

Source Distribution

gimme-that-0.3.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

gimme_that-0.3.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file gimme-that-0.3.1.tar.gz.

File metadata

  • Download URL: gimme-that-0.3.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for gimme-that-0.3.1.tar.gz
Algorithm Hash digest
SHA256 143d4551c65f625abbb9c55995a521fec68d6a34b561516919e293c8c40d72f1
MD5 12dfc9691544266b44072cf57e720561
BLAKE2b-256 27c273fdf90901ba4fb5f042a200e730ae094f48ca982240149b0fc8559afe45

See more details on using hashes here.

File details

Details for the file gimme_that-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: gimme_that-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for gimme_that-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3abf4ac9cf145714b25363aa3b387af696f771951cdbefd4f86953a4c5d38ff4
MD5 19f8fce9ff84710d03efcdb09807a58a
BLAKE2b-256 b9648430fc6d24fde977268fa63f5cad139a0facbb435d75fba961470fd3d6f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page