{"id":15696971,"url":"https://github.com/ettoreleandrotognoli/python-cdi","last_synced_at":"2026-03-16T01:38:06.304Z","repository":{"id":62579200,"uuid":"79875423","full_name":"ettoreleandrotognoli/python-cdi","owner":"ettoreleandrotognoli","description":"Python Code Dependency Injection Library","archived":false,"fork":false,"pushed_at":"2023-02-08T04:41:01.000Z","size":138,"stargazers_count":7,"open_issues_count":10,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T22:46:40.084Z","etag":null,"topics":["cdi","dependency-injection","di","injection","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ettoreleandrotognoli.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-24T03:36:50.000Z","updated_at":"2022-01-23T07:06:44.000Z","dependencies_parsed_at":"2024-10-03T19:10:42.092Z","dependency_job_id":"4223cf33-5cbd-459a-a16a-1b499db1b281","html_url":"https://github.com/ettoreleandrotognoli/python-cdi","commit_stats":{"total_commits":91,"total_committers":5,"mean_commits":18.2,"dds":0.1648351648351648,"last_synced_commit":"ea9a63a270d09b0499f4a3c269a843eda2cc785b"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ettoreleandrotognoli%2Fpython-cdi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ettoreleandrotognoli%2Fpython-cdi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ettoreleandrotognoli%2Fpython-cdi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ettoreleandrotognoli%2Fpython-cdi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ettoreleandrotognoli","download_url":"https://codeload.github.com/ettoreleandrotognoli/python-cdi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252967982,"owners_count":21833247,"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":["cdi","dependency-injection","di","injection","python"],"created_at":"2024-10-03T19:10:34.998Z","updated_at":"2026-03-16T01:38:01.273Z","avatar_url":"https://github.com/ettoreleandrotognoli.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=====\nPyCDI\n=====\n\n.. image:: https://travis-ci.org/ettoreleandrotognoli/python-cdi.svg?branch=master\n    :target: https://travis-ci.org/ettoreleandrotognoli/python-cdi\n\n.. image:: https://codecov.io/gh/ettoreleandrotognoli/python-cdi/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/ettoreleandrotognoli/python-cdi\n\n.. image:: https://badge.fury.io/py/pycdi.svg\n    :target: https://badge.fury.io/py/pycdi\n\n.. image:: https://img.shields.io/pypi/dm/pycdi.svg\n    :target: https://pypi.python.org/pypi/pycdi#downloads\n    \n.. image:: https://api.codeclimate.com/v1/badges/b17d7c12edab60606f4c/maintainability\n   :target: https://codeclimate.com/github/ettoreleandrotognoli/python-cdi/maintainability\n   :alt: Maintainability\n   \n.. image:: https://api.codeclimate.com/v1/badges/b17d7c12edab60606f4c/test_coverage\n   :target: https://codeclimate.com/github/ettoreleandrotognoli/python-cdi/test_coverage\n   :alt: Test Coverage\n\n.. image:: https://www.codefactor.io/repository/github/ettoreleandrotognoli/python-cdi/badge\n    :target: https://www.codefactor.io/repository/github/ettoreleandrotognoli/python-cdi\n    :alt: CodeFactor\n\nA simple Python CDI ( Code Dependency Injection) Library.\n\nSee the `code of conduct \u003cCODE_OF_CONDUCT.md\u003e`_.\n\nInstall\n-------\n\nInstall stable pycdi\n\n.. code-block:: shell\n\n    pip install pycdi\n\nInstall latest pycdi\n\n.. code-block:: shell\n\n    pip install git+https://github.com/ettoreleandrotognoli/python-cdi\n    \nUsage\n-----\n\nPython2 \u0026 Python3\n~~~~~~~~~~~~~~~~~\n\nYou can see more examples in the examples folder (examples/common).\n\n.. code-block:: python\n\n    import logging\n    from logging import Logger\n    \n    from pycdi import Inject, Singleton, Producer\n    from pycdi.shortcuts import call\n    \n    \n    @Producer(str, _context='app_name')\n    def get_app_name():\n        return 'PyCDI'\n    \n    \n    @Singleton(produce_type=Logger)\n    @Inject(app_name=str, _context='app_name')\n    def get_logger(app_name):\n        return logging.getLogger(app_name)\n    \n    \n    @Inject(name=(str, 'app_name'), logger=Logger)\n    def main(name, logger):\n        logger.info('I\\'m starting...')\n        print('Hello World!!!\\nI\\'m a example of %s' % name)\n        logger.debug('I\\'m finishing...')\n    \n    \n    call(main)\n\n\nPython 3\n~~~~~~~~\n\nWith Python 3 it is possible to define the types of injection with Python type hints.\n\nYou can see more examples in the examples folder( examples/py3/ ).\n\n\n.. code-block:: python\n\n    import logging\n    from logging import Logger\n    \n    from pycdi import Inject, Singleton, Producer\n    from pycdi.shortcuts import call\n    \n    \n    @Producer(_context='app_name')\n    def get_app_name() -\u003e str:\n        return 'PyCDI'\n    \n    \n    @Singleton()\n    @Inject(logger_name='app_name')\n    def get_logger(logger_name: str) -\u003e Logger:\n        return logging.getLogger(logger_name)\n    \n    \n    @Inject(name='app_name')\n    def main(name: str, logger: Logger):\n        logger.info('I\\'m starting...')\n        print('Hello World!!!\\nI\\'m an example of %s' % name)\n        logger.debug('I\\'m finishing...')\n    \n    \n    call(main)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fettoreleandrotognoli%2Fpython-cdi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fettoreleandrotognoli%2Fpython-cdi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fettoreleandrotognoli%2Fpython-cdi/lists"}