Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

injex

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

injex

DI container for Python applications

  • 1.0.0
  • PyPI
  • Socket score

Maintainers
1

Injex - DI Container for Python

Build Status pypi Python Versions License

Injex is a lightweight and easy-to-use Dependency Injection (DI) container for Python applications. It simplifies dependency management, making your code more modular, testable, and maintainable. Injex is inspired by popular DI frameworks in other programming languages and brings similar capabilities to Python.

Features

🌟 Simple API: Easy to understand and use. 🔄 Multiple Lifestyles: Support for singleton, transient, and scoped services. 🧩 Flexible Registrations: Register services, factories, and instances. 🏷️ Named Registrations: Register multiple implementations of the same interface using names. 🔍 Property Injection: Inject dependencies into properties after object creation. 🛠 Optional Dependencies: Handle optional dependencies gracefully. 🚀 No External Dependencies: Pure Python implementation without third-party packages.

Installation

pip install injex

Why Use Dependency Injection?

Dependency Injection is a design pattern that helps in:

  • Modularity: Breaking down your application into interchangeable components.
  • Testability: Facilitating unit testing by allowing dependencies to be mocked or stubbed.
  • Maintainability: Making it easier to update, replace, or refactor components without affecting other parts of the application.
  • Flexibility: Configuring different implementations of the same interface for various scenarios (e.g., testing, production).

Quick Start

Here's a simple example of usage Injex:

from abc import ABC, abstractmethod
from injex import Container

class IService(ABC):
    @abstractmethod
    def perform_action(self):
        pass

class ServiceImplementation(IService):
    def perform_action(self):
        print("Service is performing an action.")

container = Container()

container.add_transient(IService, ServiceImplementation)

service = container.resolve(IService)
service.perform_action() # output: Service is performing an action.

Another examples in examples folder.

Documentation

For detailed documentation on all functionalities, usage examples, and best practices, please refer to the Documentation.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc