Skip to main content

No project description provided

Project description

Dependency Injection Library

This is a simple Python dependency injection library that provides an easy way to register and retrieve instances of classes. It allows you to decouple class dependencies and simplifies testing and maintenance of your codebase.

Features

  • Register and retrieve instances with ease.
  • Manage dependencies using simple factory methods.
  • Supports flexible dependency injection for classes with minimal boilerplate.

Installation

To install this package, clone the repository and install the dependencies:

git clone https://github.com/mjdarvishi/python_injector
cd python_injector
pip install .

Alternatively, you can also install it directly:

pip install python-injector

Usage Registering Dependencies To register a class or service with the injector, you need to define a factory function that creates instances of the class. This is done using the Injector.register method.

from injector import Injector

# Example classes
class Repository:
    pass

class RepositoryImpl(Repository):
    pass

# Registering the implementation of the Repository
injector = Injector()
injector.register(Repository, lambda: RepositoryImpl())

# Retrieving an instance of ShopRepository
repo = injector.get(Repository)

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

python_injector-0.2.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

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

python_injector-0.2-py3-none-any.whl (2.3 kB view details)

Uploaded Python 3

File details

Details for the file python_injector-0.2.tar.gz.

File metadata

  • Download URL: python_injector-0.2.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for python_injector-0.2.tar.gz
Algorithm Hash digest
SHA256 de81aef9a74638dd4ee79c41ed3238fdfdb5cbc8a3729961083489c2bbe0de63
MD5 393b9bc2d2037f61a49b987be69c7be2
BLAKE2b-256 9596945f200ff32c21a72d8382d96015041ed9025882f82007d72d7d41aa8891

See more details on using hashes here.

File details

Details for the file python_injector-0.2-py3-none-any.whl.

File metadata

  • Download URL: python_injector-0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for python_injector-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8dae98ba753d8f9a639a04a112c1ee5076f5c589f71f66f4cf8c9ba30cd10b20
MD5 a3fbc2edf12088901d44bef5fe179ad2
BLAKE2b-256 98fcc7665b8b699bba007fb1c9784b10c04c9dbe95c3dee9503a74952d6303d4

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