{"id":13458922,"url":"https://github.com/roo-oliv/injectable","last_synced_at":"2025-04-06T11:10:03.419Z","repository":{"id":47738355,"uuid":"120220195","full_name":"roo-oliv/injectable","owner":"roo-oliv","description":"Python Dependency Injection for Humans™","archived":false,"fork":false,"pushed_at":"2024-08-05T15:13:11.000Z","size":1144,"stargazers_count":117,"open_issues_count":6,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T22:36:30.144Z","etag":null,"topics":["autowired","autowiring","circular-dependencies","dependency-injection","for-humans","injection","ioc","lazy-evaluation","micro-framework","python"],"latest_commit_sha":null,"homepage":"https://injectable.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roo-oliv.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.rst","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"roo-oliv","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2018-02-04T20:26:28.000Z","updated_at":"2025-03-23T00:03:19.000Z","dependencies_parsed_at":"2024-06-19T02:53:11.688Z","dependency_job_id":"cc148acc-2765-4cfc-9369-03309acea135","html_url":"https://github.com/roo-oliv/injectable","commit_stats":null,"previous_names":["roo-oliv/injectable","allrod5/injectable"],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roo-oliv%2Finjectable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roo-oliv%2Finjectable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roo-oliv%2Finjectable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roo-oliv%2Finjectable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roo-oliv","download_url":"https://codeload.github.com/roo-oliv/injectable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411223,"owners_count":20934650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autowired","autowiring","circular-dependencies","dependency-injection","for-humans","injection","ioc","lazy-evaluation","micro-framework","python"],"created_at":"2024-07-31T09:00:59.747Z","updated_at":"2025-04-06T11:10:03.394Z","avatar_url":"https://github.com/roo-oliv.png","language":"Python","funding_links":["https://github.com/sponsors/roo-oliv"],"categories":["Software","Python"],"sub_categories":["DI Frameworks / Containers"],"readme":".. _injectable:\n.. role:: python(code)\n   :language: python\n\nInjectable: Dependency Injection for Humans™\n============================================\n\n`Usage Examples 🚩 \u003chttps://injectable.readthedocs.io/en/latest/usage/index.html\u003e`_ | `Developer Reference 👩‍💻 \u003chttps://injectable.readthedocs.io/en/latest/reference/index.html\u003e`_ | `Authors 👫 \u003chttps://injectable.readthedocs.io/en/latest/authors.html\u003e`_\n\n.. start-badges\n\n.. list-table::\n    :stub-columns: 1\n\n    * - license\n      - |license|\n    * - docs\n      - |docs|\n    * - tests\n      - |build| |coveralls| |reliability| |security| |black| |flake8|\n    * - package\n      - |version| |wheel| |supported-versions| |supported-implementations| |platforms| |downloads|\n.. |docs| image:: https://readthedocs.org/projects/pip/badge/?version=latest\u0026style=plastic\n    :target: https://injectable.readthedocs.io/en/latest/\n    :alt: Documentation\n\n.. |build| image:: https://github.com/roo-oliv/injectable/actions/workflows/build.yml/badge.svg\n    :alt: Build Status\n    :target: https://github.com/roo-oliv/injectable/actions/workflows/build.yml\n\n.. |coveralls| image:: https://coveralls.io/repos/github/allrod5/injectable/badge.svg?branch=master\n    :alt: Coverage Status\n    :target: https://coveralls.io/github/allrod5/injectable?branch=master\n\n.. |reliability| image:: https://sonarcloud.io/api/project_badges/measure?project=roo-oliv_injectable\u0026metric=reliability_rating\n    :alt: Reliability Rating\n    :target: https://sonarcloud.io/dashboard?id=roo-oliv_injectable\n\n.. |security| image:: https://sonarcloud.io/api/project_badges/measure?project=roo-oliv_injectable\u0026metric=security_rating\n    :alt: Security Rating\n    :target: https://sonarcloud.io/dashboard?id=roo-oliv_injectable\n\n.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :alt: Code Style\n    :target: https://github.com/psf/black\n\n.. |flake8| image:: https://img.shields.io/badge/standards-flake8-blue\n    :alt: Standards\n    :target: https://flake8.pycqa.org/en/latest/\n\n.. |version| image:: https://img.shields.io/pypi/v/injectable.svg\n    :alt: PyPI Package latest release\n    :target: https://pypi.org/project/injectable\n\n.. |wheel| image:: https://img.shields.io/pypi/wheel/injectable.svg\n    :alt: PyPI Wheel\n    :target: https://pypi.org/project/injectable\n\n.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/injectable.svg\n    :alt: Supported versions\n    :target: https://pypi.org/project/injectable\n\n.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/injectable.svg\n    :alt: Supported implementations\n    :target: https://pypi.org/project/injectable\n\n.. |license| image:: https://img.shields.io/github/license/roo-oliv/injectable\n    :alt: GitHub license\n    :target: https://github.com/roo-oliv/injectable/blob/master/LICENSE\n\n.. |platforms| image:: https://img.shields.io/badge/platforms-windows%20%7C%20macos%20%7C%20linux-lightgrey\n    :alt: Supported Platforms\n    :target: https://github.com/roo-oliv/injectable/blob/master/.github/workflows/build.yml#L11\n\n.. |downloads| image:: https://pepy.tech/badge/injectable/month\n    :alt: Downloads per Month\n    :target: https://pepy.tech/project/injectable/month\n\n\n.. end-badges\n\n**Injectable** is an elegant and simple Dependency Injection framework built with Heart\nand designed for Humans.\n\n.. list-table::\n    :header-rows: 0\n\n    * - .. code:: python\n\n            from typing import Annotated, List\n            from injectable import Autowired, autowired\n            from models import Database\n            from messaging import Broker\n\n            class Service:\n                @autowired\n                def __init__(\n                    self,\n                    database: Annotated[Database, Autowired],\n                    brokers: Annotated[List[Broker], Autowired],\n                ):\n                    pending = database.get_pending_messages()\n                    for broker in brokers:\n                        broker.send_pending(pending)\n\n        .. code:: python\n\n            from abc import ABC\n\n            class Broker(ABC):\n                def send_pending(messages):\n                    ...\n\n      - .. code:: python\n\n            from injectable import injectable\n\n            @injectable\n            class Database:\n                ...\n\n        .. code:: python\n\n            from messaging import Broker\n            from injectable import injectable\n\n            @injectable\n            class KafkaProducer(Broker):\n                ...\n\n        .. code:: python\n\n            from messaging import Broker\n            from injectable import injectable\n\n            @injectable\n            class SQSProducer(Broker):\n                ...\n\nFeatures you'll love ❤️\n-----------------------\n\n* **Autowiring**: injection is\n  transparent to the function. Just decorate the function with :python:`@autowired` and annotate\n  parameters with :python:`Autowired`, that's it.\n  `see an example \u003chttps://injectable.readthedocs.io/en/latest/usage/TLDR.html\u003e`__\n\n* **Automatic dependency discovery**: just call :python:`load_injection_container()` at\n  the root of your project or pass the root path as an argument. All classes decorated\n  with :python:`@injectable` will be automatically discovered and ready for injection.\n  `see reference \u003chttps://injectable.readthedocs.io/en/latest/reference/injectable.html#injectable.load_injection_container\u003e`__\n\n* **Qualifier overloading**: declare as many injectables as you like for a single\n  qualifier or extending the same base class. You can inject all of them just by\n  specifying a :python:`typing.List` to :python:`Autowired`:\n  :python:`deps: Annotated[List[\"qualifier\"], Autowired]`.\n  `see an example \u003chttps://injectable.readthedocs.io/en/latest/usage/qualifier_overloading.html\u003e`__\n\n* **Transparent lazy initialization**: passing the argument :python:`lazy=True` for\n  :python:`Autowired` will make your dependency to be initialized only when actually used, all\n  in a transparent fashion.\n  `see an example \u003chttps://injectable.readthedocs.io/en/latest/usage/lazy_injection.html\u003e`__\n\n* **Singletons**: decorate your class with :python:`@injectable(singleton=True)` and only a\n  single instance will be initialized and shared for injection.\n  `see an example \u003chttps://injectable.readthedocs.io/en/latest/usage/singletons.html\u003e`__\n\n* **Namespaces**: specify different namespaces for injectables as in\n  :python:`@injectable(namespace=\"foo\")` and then just use them when annotating your\n  parameters as in :python:`dep: Annotated[..., Autowired(namespace=\"foo\")]`.\n  `see an example \u003chttps://injectable.readthedocs.io/en/latest/usage/namespaces.html\u003e`__\n\n* **Linters friendly**: :python:`Autowired` is carefully designed to comply with static linter\n  analysis such as PyCharm's to preserve the parameter original type hint.\n\nThese are just a few cool and carefully built features for you. Check out our `docs\n\u003chttps://injectable.readthedocs.io/en/latest/\u003e`_!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froo-oliv%2Finjectable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froo-oliv%2Finjectable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froo-oliv%2Finjectable/lists"}