linkd


Namelinkd JSON
Version 0.0.10 PyPI version JSON
download
home_pageNone
SummaryA powerful async-only dependency injection framework for Python.
upload_time2025-07-25 15:29:56
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.10.0
licenseNone
keywords ioc dependency injection injection inversion of control asyncio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI](https://img.shields.io/pypi/v/linkd)](https://pypi.org/project/linkd) [![codecov](https://codecov.io/gh/tandemdude/linkd/graph/badge.svg?token=hZZlq0O9Vx)](https://codecov.io/gh/tandemdude/linkd)

# Overview
Linkd is a powerful [dependency-injection](https://en.wikipedia.org/wiki/Dependency_injection) framework for
asyncio-based Python applications.

This library aims to provide an easy way for framework developers to provide dependency-injection functionality,
while also being suitable for use with standalone applications with a little bit more work.

For an example of `linkd` in action, have a look at [`hikari-lightbulb`](https://github.com/tandemdude/hikari-lightbulb) which
uses it to provide all dependency injection functionality.

## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install linkd.

```bash
pip install linkd
```

## Usage

### Standalone

The most basic usage of linkd involves three main steps:
- Creating a `DependencyInjectionManager` and registering dependencies
- Setting up an injection context
- Enabling injection on a function

An example of all the above can be seen below:

```python
import asyncio

import linkd

# create a manager instance
manager = linkd.DependencyInjectionManager()
# register a dependency to on of the manager's registries
manager.registry_for(linkd.Contexts.ROOT).register_value(str, "thomm.o")

# enable injection on a function with the inject decorator
@linkd.inject
async def greet(who: str) -> str:
    # the 'who' parameter will be injected by linkd
    return f"hello {who}"


# use the contextual decorator to automatically set up an injection context
@manager.contextual(linkd.Contexts.ROOT)
async def main() -> None:
    # call the injected method
    print(await greet())


if __name__ == "__main__":
    asyncio.run(main())
```

### Supported Framework

Linkd currently supports the following frameworks (click to jump to example usage):
- [FastAPI](https://github.com/tandemdude/linkd/blob/master/examples/fastapi_example.py)
- [Quart](https://github.com/tandemdude/linkd/blob/master/examples/quart_example.py)
- [Starlette](https://github.com/tandemdude/linkd/blob/master/examples/starlette_example.py)

If your framework isn't mentioned here, feel free to open an issue requesting support!

## Issues
If you find any bugs, issues, or unexpected behaviour while using the library,
you should open an issue with details of the problem and how to reproduce if possible.
Please also open an issue for any new features you would like to see added.

## Contributing
Pull requests are welcome. For major changes, please open an issue/discussion first to discuss what you would like to change.

Please try to ensure that documentation is updated if you add any features accessible through the public API.

If you use this library and like it, feel free to sign up to GitHub and star the project,
it is greatly appreciated and lets me know that I'm going in the right direction!

## Links
- **License:** [MIT](https://choosealicense.com/licenses/mit/)
- **Repository:** [GitHub](https://github.com/tandemdude/linkd)
- **Documentation:** [ReadTheDocs](https://linkd.readthedocs.io/en/latest/)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "linkd",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.10.0",
    "maintainer_email": null,
    "keywords": "ioc, dependency injection, injection, inversion of control, asyncio",
    "author": null,
    "author_email": "tandemdude <tandemdude1@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d0/de/4aa22044fab18f681a9f5d63e8e18ec41683f6b478da464f6d413eebc906/linkd-0.0.10.tar.gz",
    "platform": null,
    "description": "[![PyPI](https://img.shields.io/pypi/v/linkd)](https://pypi.org/project/linkd) [![codecov](https://codecov.io/gh/tandemdude/linkd/graph/badge.svg?token=hZZlq0O9Vx)](https://codecov.io/gh/tandemdude/linkd)\n\n# Overview\nLinkd is a powerful [dependency-injection](https://en.wikipedia.org/wiki/Dependency_injection) framework for\nasyncio-based Python applications.\n\nThis library aims to provide an easy way for framework developers to provide dependency-injection functionality,\nwhile also being suitable for use with standalone applications with a little bit more work.\n\nFor an example of `linkd` in action, have a look at [`hikari-lightbulb`](https://github.com/tandemdude/hikari-lightbulb) which\nuses it to provide all dependency injection functionality.\n\n## Installation\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install linkd.\n\n```bash\npip install linkd\n```\n\n## Usage\n\n### Standalone\n\nThe most basic usage of linkd involves three main steps:\n- Creating a `DependencyInjectionManager` and registering dependencies\n- Setting up an injection context\n- Enabling injection on a function\n\nAn example of all the above can be seen below:\n\n```python\nimport asyncio\n\nimport linkd\n\n# create a manager instance\nmanager = linkd.DependencyInjectionManager()\n# register a dependency to on of the manager's registries\nmanager.registry_for(linkd.Contexts.ROOT).register_value(str, \"thomm.o\")\n\n# enable injection on a function with the inject decorator\n@linkd.inject\nasync def greet(who: str) -> str:\n    # the 'who' parameter will be injected by linkd\n    return f\"hello {who}\"\n\n\n# use the contextual decorator to automatically set up an injection context\n@manager.contextual(linkd.Contexts.ROOT)\nasync def main() -> None:\n    # call the injected method\n    print(await greet())\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### Supported Framework\n\nLinkd currently supports the following frameworks (click to jump to example usage):\n- [FastAPI](https://github.com/tandemdude/linkd/blob/master/examples/fastapi_example.py)\n- [Quart](https://github.com/tandemdude/linkd/blob/master/examples/quart_example.py)\n- [Starlette](https://github.com/tandemdude/linkd/blob/master/examples/starlette_example.py)\n\nIf your framework isn't mentioned here, feel free to open an issue requesting support!\n\n## Issues\nIf you find any bugs, issues, or unexpected behaviour while using the library,\nyou should open an issue with details of the problem and how to reproduce if possible.\nPlease also open an issue for any new features you would like to see added.\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue/discussion first to discuss what you would like to change.\n\nPlease try to ensure that documentation is updated if you add any features accessible through the public API.\n\nIf you use this library and like it, feel free to sign up to GitHub and star the project,\nit is greatly appreciated and lets me know that I'm going in the right direction!\n\n## Links\n- **License:** [MIT](https://choosealicense.com/licenses/mit/)\n- **Repository:** [GitHub](https://github.com/tandemdude/linkd)\n- **Documentation:** [ReadTheDocs](https://linkd.readthedocs.io/en/latest/)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A powerful async-only dependency injection framework for Python.",
    "version": "0.0.10",
    "project_urls": {
        "Changelog": "https://linkd.readthedocs.io/en/latest/changelog.html",
        "Documentation": "https://linkd.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/tandemdude/linkd",
        "Repository": "https://github.com/tandemdude/linkd"
    },
    "split_keywords": [
        "ioc",
        " dependency injection",
        " injection",
        " inversion of control",
        " asyncio"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "43488a5992965a029691237ddb5c9306a12e7ff8296e52bf8f47230abd535b2b",
                "md5": "c79ec33cee699d07a1d7e14b8ece0770",
                "sha256": "d52a19109c3b9be699f096b29a0d2554f51417e6b30b85bf32e5f7d41c72e567"
            },
            "downloads": -1,
            "filename": "linkd-0.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c79ec33cee699d07a1d7e14b8ece0770",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.10.0",
            "size": 38857,
            "upload_time": "2025-07-25T15:29:55",
            "upload_time_iso_8601": "2025-07-25T15:29:55.571726Z",
            "url": "https://files.pythonhosted.org/packages/43/48/8a5992965a029691237ddb5c9306a12e7ff8296e52bf8f47230abd535b2b/linkd-0.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d0de4aa22044fab18f681a9f5d63e8e18ec41683f6b478da464f6d413eebc906",
                "md5": "87841e9a0139820397509f36370b8169",
                "sha256": "40b7ba0e01373bcb9baa6118d8ae439f2d40a0a9dda7e436fde3965b970c5cb0"
            },
            "downloads": -1,
            "filename": "linkd-0.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "87841e9a0139820397509f36370b8169",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.10.0",
            "size": 43224,
            "upload_time": "2025-07-25T15:29:56",
            "upload_time_iso_8601": "2025-07-25T15:29:56.927148Z",
            "url": "https://files.pythonhosted.org/packages/d0/de/4aa22044fab18f681a9f5d63e8e18ec41683f6b478da464f6d413eebc906/linkd-0.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-25 15:29:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tandemdude",
    "github_project": "linkd",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "linkd"
}
        
Elapsed time: 1.21476s