Skip to main content

Simple DI Framework for Python 3.x 🐍

Project description

Repository Icon

BindMe

BindMe Logo

Simple DI Framework for Python 3.x 🐍


Usage

Installation Instructions:

To install the package, run:

pip install bindme


Features

Interesting Highlights:

    Simple 📕 - everything you need is here!

    Fast ⚡ - awesome work speed!

    Low 🍃 - weighs nothing at all!

DI meme 1 Logo


Use Cases

Examples:

project structure

# create interface

from abc import ABC, abstractmethod
from typing import Any, NoReturn


class ItemServiceInterface:
    @abstractmethod
    def create_one(self, dto: dict[str, Any]) -> NoReturn:
        raise NotImplementedError("<create one> method is not implemented!")

    @abstractmethod
    def get_one(self, dto: dict[str, Any]) -> NoReturn:
        raise NotImplementedError("<get one> method is not implemented!")


# create implement

from src.interfaces import ItemServiceInterface


class ItemServiceImplement(ItemServiceInterface):
    def create_one(self, dto: dict[str, Any]) -> None:
        print(f"Item with {dto} is created!")

    def get_one(self, dto: dict[str, Any]) -> None:
        print(f"Item with {dto} is get!")


# configure bindme


from bindme import container

from src.interfaces.item import ItemServiceInterface
from src.implements.item import ItemServiceImplement

container.register(abstract_class=ItemServiceInterface, concrete_class=ItemServiceImplement)

# use container directly from code

from bindme import container

from src.implements.item import ItemServiceInterface


def get_item_service():
    item_service = container.resolve(abstract_class=ItemServiceInterface)
    item_service.create_one({"name": "Bob"})
    # item_service.get_one({"name": "Bob"})


get_item_service()

# use @injection decorator

from bindme import inject

from src.implements.item import ItemServiceInterface


@inject
def get_item_service(item_service: ItemServiceInterface):
    item_service.create_one(dto={"name": "Bob"})
    # item_service.get_one(dto={"name": "Bob"})


get_item_service(item_service=ItemServiceImplement)

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

bindme-0.2.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bindme-0.2.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file bindme-0.2.0.tar.gz.

File metadata

  • Download URL: bindme-0.2.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for bindme-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d5b64a0231064073e94085008769ddb4cb2a5595b76ef15799a3e14270f1a030
MD5 2adeb3c2a966f7db476bb89745ca5da5
BLAKE2b-256 fd44bcaaf19f03b0b605bb0609e1f951f6ea1510dd9f2b6afd8cfbbca4ec1407

See more details on using hashes here.

File details

Details for the file bindme-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bindme-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for bindme-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9db6c0d7534b700a97d3608037b4d5f3eb9d29489a59b54b99d6857a79fb3f2
MD5 f0a4d67fb3ef0d76d951099418cb1c1d
BLAKE2b-256 5eb6faa817d46419f71c7469b20824f49c34798a2850d4adf51002d2d831d527

See more details on using hashes here.

Supported by

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