injex


Nameinjex JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryDI container for Python applications
upload_time2024-11-16 21:04:57
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords dependency injection di container ddd
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Injex - DI Container for Python

![Build Status](https://github.com/vshulcz/di/actions/workflows/ci.yml/badge.svg)
[![pypi](https://img.shields.io/pypi/v/injex.svg)](https://pypi.python.org/pypi/injex)
[![Python Versions](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12%20|%203.13-blue)](https://github.com/vshulcz/injex)
[![License](https://img.shields.io/github/license/vshulcz/di.svg)](https://github.com/vshulcz/injex/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

```bash
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:
```python
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](./examples).

## Documentation

For detailed documentation on all functionalities, usage examples, and best practices, please refer to the [Documentation](./docs/tutorial.md).

## Contributing

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "injex",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "dependency, injection, di, container, ddd",
    "author": null,
    "author_email": "vshulcz <vshulcz@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f9/33/5c91af99bb073f2a7da26ea8fedeb4cf2952653eae732e69da549ef80d77/injex-1.0.0.tar.gz",
    "platform": null,
    "description": "# Injex - DI Container for Python\n\n![Build Status](https://github.com/vshulcz/di/actions/workflows/ci.yml/badge.svg)\n[![pypi](https://img.shields.io/pypi/v/injex.svg)](https://pypi.python.org/pypi/injex)\n[![Python Versions](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12%20|%203.13-blue)](https://github.com/vshulcz/injex)\n[![License](https://img.shields.io/github/license/vshulcz/di.svg)](https://github.com/vshulcz/injex/LICENSE)\n\nInjex 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.\n\n## Features\n\n\ud83c\udf1f Simple API: Easy to understand and use.\n\ud83d\udd04 Multiple Lifestyles: Support for singleton, transient, and scoped services.\n\ud83e\udde9 Flexible Registrations: Register services, factories, and instances.\n\ud83c\udff7\ufe0f Named Registrations: Register multiple implementations of the same interface using names.\n\ud83d\udd0d Property Injection: Inject dependencies into properties after object creation.\n\ud83d\udee0 Optional Dependencies: Handle optional dependencies gracefully.\n\ud83d\ude80 No External Dependencies: Pure Python implementation without third-party packages.\n\n## Installation\n\n```bash\npip install injex\n```\n\n## Why Use Dependency Injection?\n\n**Dependency Injection is a design pattern that helps in:**\n\n* Modularity: Breaking down your application into interchangeable components.\n* Testability: Facilitating unit testing by allowing dependencies to be mocked or stubbed.\n* Maintainability: Making it easier to update, replace, or refactor components without affecting other parts of the application.\n* Flexibility: Configuring different implementations of the same interface for various scenarios (e.g., testing, production).\n\n## Quick Start\n\nHere's a simple example of usage Injex:\n```python\nfrom abc import ABC, abstractmethod\nfrom injex import Container\n\nclass IService(ABC):\n    @abstractmethod\n    def perform_action(self):\n        pass\n\nclass ServiceImplementation(IService):\n    def perform_action(self):\n        print(\"Service is performing an action.\")\n\ncontainer = Container()\n\ncontainer.add_transient(IService, ServiceImplementation)\n\nservice = container.resolve(IService)\nservice.perform_action() # output: Service is performing an action.\n```\nAnother examples in [examples folder](./examples).\n\n## Documentation\n\nFor detailed documentation on all functionalities, usage examples, and best practices, please refer to the [Documentation](./docs/tutorial.md).\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "DI container for Python applications",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/vshulcz/injex"
    },
    "split_keywords": [
        "dependency",
        " injection",
        " di",
        " container",
        " ddd"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5e43bbf72126c82e0eec2a0803fe1df183cba9fb4e27c89fa7cad3f7b7d18965",
                "md5": "e87c9583cb7c7f130b63ff98763439d4",
                "sha256": "72ebba6d6626d0405d433e3080f0ea85526876801acba1590f1a84e5362a5c1d"
            },
            "downloads": -1,
            "filename": "injex-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e87c9583cb7c7f130b63ff98763439d4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 5947,
            "upload_time": "2024-11-16T21:04:55",
            "upload_time_iso_8601": "2024-11-16T21:04:55.442210Z",
            "url": "https://files.pythonhosted.org/packages/5e/43/bbf72126c82e0eec2a0803fe1df183cba9fb4e27c89fa7cad3f7b7d18965/injex-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f9335c91af99bb073f2a7da26ea8fedeb4cf2952653eae732e69da549ef80d77",
                "md5": "922efceec82dc0cd8172b91596c69658",
                "sha256": "56292381b06cc8314a0adf42bc6b633f5a3ef2d82d6a33611f071720fb3acbee"
            },
            "downloads": -1,
            "filename": "injex-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "922efceec82dc0cd8172b91596c69658",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 9462,
            "upload_time": "2024-11-16T21:04:57",
            "upload_time_iso_8601": "2024-11-16T21:04:57.511206Z",
            "url": "https://files.pythonhosted.org/packages/f9/33/5c91af99bb073f2a7da26ea8fedeb4cf2952653eae732e69da549ef80d77/injex-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-16 21:04:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vshulcz",
    "github_project": "injex",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "injex"
}
        
Elapsed time: 0.68735s