explicit-di


Nameexplicit-di JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/depeche-py/explicit-di
Summary
upload_time2023-10-26 19:08:04
maintainer
docs_urlNone
authorMartin Vielsmaier
requires_python>=3.9,<4.0
license
keywords dependency-injection di dependency-injection-container
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Explicit DI

A library for explicit Dependency Injection

[![Tests](https://github.com/depeche-py/explicit-di/actions/workflows/tests.yml/badge.svg)](https://github.com/depeche-py/explicit-di/actions/workflows/tests.yml)
[![pypi](https://img.shields.io/pypi/v/explicit-di.svg)](https://pypi.python.org/pypi/explicit-di)
[![versions](https://img.shields.io/pypi/pyversions/explicit-di.svg)](https://github.com/depeche-py/explicit-di)
[![Docs](https://img.shields.io/badge/docs-here-green.svg)](https://depeche-py.github.io/explicit-di/)
[![license](https://img.shields.io/github/license/depeche-py/explicit-di.svg)](https://github.com/depeche-py/explicit-di/blob/main/LICENSE)

---

**Documentation**: [https://depeche-py.github.io/explicit-di/](https://depeche-py.github.io/explicit-di/)

**Source code**: [https://github.com/depeche-py/explicit-di](https://github.com/depeche-py/explicit-di)

---

Explicit DI is modern Python library for explicit Dependency Injection

## Requirements

Python 3.9+


## Installation

```bash
pip install explicit-di
# OR
poetry add explicit-di
```

## Example

```python
import explicit_di as _di


class A:
    pass


class B:
    def __init__(self, a: A, config : str):
        self.config = config
        self.a = a


class C:
    def __init__(self, b: B):
        self.b = b


def create_b(a: A):
    return B(a=a, config="foo")


def function_with_dependencies(one : int, two : str, my_c : C):
    print(my_c)


def main():
    container = _di.Container()
    container.register(A)
    container.register(B, create_b)
    container.register(C)

    b = container.resolve(B)
    assert isinstance(b, B)

    container.inject(function_with_dependencies, one=1, two="two")
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/depeche-py/explicit-di",
    "name": "explicit-di",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "dependency-injection,di,dependency-injection-container",
    "author": "Martin Vielsmaier",
    "author_email": "martin@vielsmaier.net",
    "download_url": "https://files.pythonhosted.org/packages/19/f4/616415d99741b9b00d454b0e544d189031b725ab55e12b102864b179f459/explicit_di-0.1.2.tar.gz",
    "platform": null,
    "description": "# Explicit DI\n\nA library for explicit Dependency Injection\n\n[![Tests](https://github.com/depeche-py/explicit-di/actions/workflows/tests.yml/badge.svg)](https://github.com/depeche-py/explicit-di/actions/workflows/tests.yml)\n[![pypi](https://img.shields.io/pypi/v/explicit-di.svg)](https://pypi.python.org/pypi/explicit-di)\n[![versions](https://img.shields.io/pypi/pyversions/explicit-di.svg)](https://github.com/depeche-py/explicit-di)\n[![Docs](https://img.shields.io/badge/docs-here-green.svg)](https://depeche-py.github.io/explicit-di/)\n[![license](https://img.shields.io/github/license/depeche-py/explicit-di.svg)](https://github.com/depeche-py/explicit-di/blob/main/LICENSE)\n\n---\n\n**Documentation**: [https://depeche-py.github.io/explicit-di/](https://depeche-py.github.io/explicit-di/)\n\n**Source code**: [https://github.com/depeche-py/explicit-di](https://github.com/depeche-py/explicit-di)\n\n---\n\nExplicit DI is modern Python library for explicit Dependency Injection\n\n## Requirements\n\nPython 3.9+\n\n\n## Installation\n\n```bash\npip install explicit-di\n# OR\npoetry add explicit-di\n```\n\n## Example\n\n```python\nimport explicit_di as _di\n\n\nclass A:\n    pass\n\n\nclass B:\n    def __init__(self, a: A, config : str):\n        self.config = config\n        self.a = a\n\n\nclass C:\n    def __init__(self, b: B):\n        self.b = b\n\n\ndef create_b(a: A):\n    return B(a=a, config=\"foo\")\n\n\ndef function_with_dependencies(one : int, two : str, my_c : C):\n    print(my_c)\n\n\ndef main():\n    container = _di.Container()\n    container.register(A)\n    container.register(B, create_b)\n    container.register(C)\n\n    b = container.resolve(B)\n    assert isinstance(b, B)\n\n    container.inject(function_with_dependencies, one=1, two=\"two\")\n```\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "0.1.2",
    "project_urls": {
        "Changelog": "https://depeche-py.github.io/explicit-di/CHANGELOG/",
        "Documentation": "https://depeche-py.github.io/explicit-di/",
        "Homepage": "https://github.com/depeche-py/explicit-di",
        "Repository": "https://github.com/depeche-py/explicit-di"
    },
    "split_keywords": [
        "dependency-injection",
        "di",
        "dependency-injection-container"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fbadb11efb5993f7e2e6b456f44f8b443d3e112bc62ea957b2cbf914d3a660f2",
                "md5": "292a4cb1831a0e77db6aa3f3848790cb",
                "sha256": "a2a9da81eef2a0958e61202f056f50789a3b8b3903421047d017c3435141b6a4"
            },
            "downloads": -1,
            "filename": "explicit_di-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "292a4cb1831a0e77db6aa3f3848790cb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 3791,
            "upload_time": "2023-10-26T19:08:03",
            "upload_time_iso_8601": "2023-10-26T19:08:03.063596Z",
            "url": "https://files.pythonhosted.org/packages/fb/ad/b11efb5993f7e2e6b456f44f8b443d3e112bc62ea957b2cbf914d3a660f2/explicit_di-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "19f4616415d99741b9b00d454b0e544d189031b725ab55e12b102864b179f459",
                "md5": "b486898c5e0f00279d218444ecae0077",
                "sha256": "ab8ed9e9a21cb5f38173e2fffe41729f36d5dfc2173a016f0aace88a4b3b95c6"
            },
            "downloads": -1,
            "filename": "explicit_di-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "b486898c5e0f00279d218444ecae0077",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 3423,
            "upload_time": "2023-10-26T19:08:04",
            "upload_time_iso_8601": "2023-10-26T19:08:04.757467Z",
            "url": "https://files.pythonhosted.org/packages/19/f4/616415d99741b9b00d454b0e544d189031b725ab55e12b102864b179f459/explicit_di-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-26 19:08:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "depeche-py",
    "github_project": "explicit-di",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "explicit-di"
}
        
Elapsed time: 0.13176s