{ "info": { "author": "RobertoPrevato", "author_email": "roberto.prevato@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "[![Build status](https://dev.azure.com/robertoprevato/rodi/_apis/build/status/rodi-CI)](https://dev.azure.com/robertoprevato/rodi/_build/latest?definitionId=8) [![pypi](https://robertoprevato.vsrm.visualstudio.com/_apis/public/Release/badge/06ceb1f2-6ca8-4981-97ca-14cc8b599bc7/1/2)](https://pypi.org/project/rodi/) [![Test coverage](https://img.shields.io/azure-devops/coverage/robertoprevato/rodi/8.svg)](https://robertoprevato.visualstudio.com/rodi/_build?definitionId=8)\n\n# Implementation of dependency injection for Python 3\n\n**Features:**\n* types resolution by signature types annotations (_type hints_)\n* types resolution by constructor parameter names and aliases (_convention over configuration_)\n* unintrusive: builds objects graph **without** the need to change classes source code (unlike some other Python implementations of dependency injection, like _[inject](https://pypi.org/project/Inject/)_)\n* minimum overhead to obtain services, once the objects graph is built\n* support for singletons, transient and scoped services\n\nThis library is freely inspired by .NET Standard `Microsoft.Extensions.DependencyInjection` implementation (_ref. [MSDN, Dependency injection in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-2.1), [Using dependency injection in a .Net Core console application](https://andrewlock.net/using-dependency-injection-in-a-net-core-console-application/)_).\n\nThe idea of writing this library was strengthened by this article by [Bob Gregory](https://twitter.com/bob_the_mighty): _[Dependency Injection with Type Signatures in Python](https://io.made.com/dependency-injection-with-type-signatures-in-python/)_. Even before reading Gregory's article, I shared many of the ideas he described in his blog.\n\n## Installation\n\n```bash\npip install rodi\n```\n\n## De gustibus non disputandum est\nThis library is designed to work both by type hints in constructor signatures, and by constructor parameter names (convention over configuration), like described in below diagram. It can be useful for those who like type hinting, those who don't, and those who like having both options.\n\n![Usage option](https://raw.githubusercontent.com/RobertoPrevato/rodi/master/documentation/rodi-design-taste.png \"Usage option\")\n\n## Minimum overhead\n`rodi` works by inspecting ____init____ methods **once** at runtime, to generate functions that return instances of desired types. Validation steps, for example to detect circular dependencies or missing services, are done when building these functions, so additional validation is not needed when activating services.\n\nFor this reason, services are first registered inside an instance of _Container_ class, which implements a method _build_provider()_ that returns an instance of _Services_. The service provider is then used to obtain desired services by type or name. Inspection and validation steps are done only when creating an instance of service provider.\n\n![Classes](https://raw.githubusercontent.com/RobertoPrevato/rodi/master/documentation/classes.png \"Classes\")\n\nIn the example below, a singleton is registered by exact instance.\n\n```python\ncontainer = Container()\ncontainer.add_instance(Cat(\"Celine\"))\n\nservices = container.build_provider() # --> validation, generation of functions\n\ncat = services.get(Cat)\n\nassert cat is not None\nassert cat.name == \"Celine\"\n```\n\n## Service life style:\n* singleton - instantiated only once per service provider\n* transient - services are instantiated every time they are required\n* scoped - instantiated only once per service resolution (root call, e.g. once per web request)\n\n# Documentation\nFor documentation and examples, please refer to the [wiki in GitHub, https://github.com/RobertoPrevato/rodi/wiki](https://github.com/RobertoPrevato/rodi/wiki).\n\n---\n\n# Develop and run tests locally\n```bash\npip install -r dev_requirements.txt\n\n# run tests using automatic discovery:\npytest\n```\n\n## Public project in Azure DevOps\n[https://dev.azure.com/robertoprevato/rodi](https://dev.azure.com/robertoprevato/rodi) - see here the project in Azure DevOps, with [builds](https://dev.azure.com/robertoprevato/rodi/_build?definitionId=8) and other goodness.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/RobertoPrevato/rodi", "keywords": "dependency injection type hints typing convention", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "rodi", "package_url": "https://pypi.org/project/rodi/", "platform": "", "project_url": "https://pypi.org/project/rodi/", "project_urls": { "Homepage": "https://github.com/RobertoPrevato/rodi" }, "release_url": "https://pypi.org/project/rodi/1.0.8/", "requires_dist": null, "requires_python": "", "summary": "Implementation of dependency injection for Python 3", "version": "1.0.8" }, "last_serial": 5376306, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "7492a44aef793e5aedf956e499177c5e", "sha256": "3dc6125cfb0d5628f8b328131045155e055da8114d6fc6a0494c9b7b2ebb59e3" }, "downloads": -1, "filename": "rodi-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7492a44aef793e5aedf956e499177c5e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7898, "upload_time": "2018-10-06T08:42:50", "url": "https://files.pythonhosted.org/packages/56/8c/2caa108f0f93b41e19d032f795af076cbaabde7827ddd925b33795a72cb6/rodi-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3345597ff896db6c860b4d3a168e6686", "sha256": "4c85d06f85327df33fb93ebef87b3edef85c1f053f04aa132941c0f926a0ce80" }, "downloads": -1, "filename": "rodi-1.0.0.tar.gz", "has_sig": false, "md5_digest": "3345597ff896db6c860b4d3a168e6686", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7757, "upload_time": "2018-10-06T08:42:52", "url": "https://files.pythonhosted.org/packages/bd/8f/fdc47b3501d86d2b28fe91711cc5024e8427b182becc01d35937d77e6a22/rodi-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "c95db975a757e60ebcc462ee9c17b3e7", "sha256": "9587b219de4ed2896711ab64d1bb1a13b6de07f3a4f2b888f8334103a514d61c" }, "downloads": -1, "filename": "rodi-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c95db975a757e60ebcc462ee9c17b3e7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8229, "upload_time": "2018-10-20T20:22:20", "url": "https://files.pythonhosted.org/packages/b6/e0/d383558d023c29b905bbc97e0564d76322a658623c1394e24201e060fb32/rodi-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e104dcc9af37661d356a06cabb69068c", "sha256": "ae7d376fb56592049a2d7f7c04bb377892eb0596262ed10ce2fae049a6ed8a5e" }, "downloads": -1, "filename": "rodi-1.0.1.tar.gz", "has_sig": false, "md5_digest": "e104dcc9af37661d356a06cabb69068c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9553, "upload_time": "2018-10-20T20:22:21", "url": "https://files.pythonhosted.org/packages/92/27/6451147a31cbadb5e4733d54e3c75ca234c72bfe7957d1fe10410330143f/rodi-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "6e7e747a0aa400c9fdcb920aced39ab0", "sha256": "297bde5f00fb4fb65a51ec110dfc8d2d2392beb6d01496788e5b5d49d663b10e" }, "downloads": -1, "filename": "rodi-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "6e7e747a0aa400c9fdcb920aced39ab0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8159, "upload_time": "2018-10-28T22:35:00", "url": "https://files.pythonhosted.org/packages/fe/e8/154553641429be0ddc7b8b3c47581f5eafa1943598b27127cc70f0dde931/rodi-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b72c4fdce73ea92304f0d307f53b0143", "sha256": "45a58376e5d9cf63b0ff160c45c737640b0dbeb12e97beb249fe008de1577613" }, "downloads": -1, "filename": "rodi-1.0.2.tar.gz", "has_sig": false, "md5_digest": "b72c4fdce73ea92304f0d307f53b0143", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9376, "upload_time": "2018-10-28T22:35:01", "url": "https://files.pythonhosted.org/packages/cf/f7/2e7a5dce812f6aa8d81e6b393cdbdd0b58542bc3df8c5766fa523f883f5c/rodi-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "eaa5fe58c1f18241aef4b4de921795fc", "sha256": "cd482824666b44fad329dcf82177a0d67fde9698937b8a15824e27f0862e393b" }, "downloads": -1, "filename": "rodi-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "eaa5fe58c1f18241aef4b4de921795fc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8357, "upload_time": "2019-01-09T15:24:59", "url": "https://files.pythonhosted.org/packages/bd/c3/04c0fa70a9369960274eea7373dae2cbecfc593f13e5f113d8d5c6f97c61/rodi-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a8559358a32efc643627d0cc15564d2d", "sha256": "8f3ffb37f00703d6e42878c050ee22b4298095431b64c9d4f65f88f4e0d26567" }, "downloads": -1, "filename": "rodi-1.0.3.tar.gz", "has_sig": false, "md5_digest": "a8559358a32efc643627d0cc15564d2d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8613, "upload_time": "2019-01-09T15:25:01", "url": "https://files.pythonhosted.org/packages/71/2b/fc80f8eac168ee18cba50ca91f11ad6a8ab43d72210da989e1565d3e76a1/rodi-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "760e4937dd9439f8b199b6de7754aa48", "sha256": "f6047354bd023157894bf5f2c1d2850113fa47218c8e98c59320a2cd8acfb4ee" }, "downloads": -1, "filename": "rodi-1.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "760e4937dd9439f8b199b6de7754aa48", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8359, "upload_time": "2019-01-09T15:39:52", "url": "https://files.pythonhosted.org/packages/3d/89/e93f2c7113d3da1db5f4fa252ee8c65ee8b83d831417e132dac144a89e64/rodi-1.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "60973f673f0a8930d191f148f246f5cb", "sha256": "58a3c946c3182dc9090fb26b30bc81c16082cd9453f547e44963c29dbf4e49dc" }, "downloads": -1, "filename": "rodi-1.0.4.tar.gz", "has_sig": false, "md5_digest": "60973f673f0a8930d191f148f246f5cb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8612, "upload_time": "2019-01-09T15:39:53", "url": "https://files.pythonhosted.org/packages/c0/d2/3bdbd5f8357cd8ae1eead0bb99c657802d5874c5cb542a444502268814f9/rodi-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "98cf64d5cf8b26cadf590c1c9451fcc7", "sha256": "f7bce220bf68bd10579157ae6d252dc601794e770cd3808d221d998b2f53e315" }, "downloads": -1, "filename": "rodi-1.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "98cf64d5cf8b26cadf590c1c9451fcc7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8619, "upload_time": "2019-05-17T21:58:29", "url": "https://files.pythonhosted.org/packages/e5/dd/758e07e26158794499660a82bf02652ec3b828b786c23d8e2be3ca04d3e9/rodi-1.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "09c56b02eb902917708be761c2c1639e", "sha256": "cc142f730e7d135c142e8e0a9f4ea6d5bbb012857dca3ce2de60d36986773b57" }, "downloads": -1, "filename": "rodi-1.0.5.tar.gz", "has_sig": false, "md5_digest": "09c56b02eb902917708be761c2c1639e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9956, "upload_time": "2019-05-17T21:58:31", "url": "https://files.pythonhosted.org/packages/2f/cb/72bf8b5c13db6ced010d9291a81fcf28dbc1fd72b742862b0d494451612e/rodi-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "a89c99183b275e113e68065c195cc9af", "sha256": "7db9cc3389a90eb2d3e25f8b8614a7e7ae35d7aab7e8e7b31e0758cfe5507830" }, "downloads": -1, "filename": "rodi-1.0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "a89c99183b275e113e68065c195cc9af", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8855, "upload_time": "2019-05-20T18:02:45", "url": "https://files.pythonhosted.org/packages/ce/7a/a9b042bb04c2301b9138d40e7e24cacd0f880f7b456a1d0720a1b933652e/rodi-1.0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aa7e8affff6fb6c17cb24a53f173fa88", "sha256": "338f9feb3ab19a75ef2ef079a21f48f9d1817431afbe86c481448a72e1a3a573" }, "downloads": -1, "filename": "rodi-1.0.6.tar.gz", "has_sig": false, "md5_digest": "aa7e8affff6fb6c17cb24a53f173fa88", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10462, "upload_time": "2019-05-20T18:02:47", "url": "https://files.pythonhosted.org/packages/de/35/07768bd97a5de57eeb7e8e9a705dbf605e4829115e703d53a49cf8c28610/rodi-1.0.6.tar.gz" } ], "1.0.7": [ { "comment_text": "", "digests": { "md5": "7c86416715c3aecb502b53b943c8b350", "sha256": "a825258e3d5ee0eb98dc53dc21811e84e7c960ac768c37d3849e69f047b836d9" }, "downloads": -1, "filename": "rodi-1.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "7c86416715c3aecb502b53b943c8b350", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8853, "upload_time": "2019-05-21T22:08:28", "url": "https://files.pythonhosted.org/packages/f3/92/c48d7b4c78441450ba2992684ed07b63a3d58e59e46cac08f1ebd4978049/rodi-1.0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "96c73eec89e25121331fb584076655e5", "sha256": "1369b8dba9275a10b71bc76254d81c7bed06a93b8ae80d3c5cfbbcafee1e35d2" }, "downloads": -1, "filename": "rodi-1.0.7.tar.gz", "has_sig": false, "md5_digest": "96c73eec89e25121331fb584076655e5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10457, "upload_time": "2019-05-21T22:08:29", "url": "https://files.pythonhosted.org/packages/10/68/1e9995f36c1a01065ff2544f42d4a12259606c354f33150b4d80887a1f49/rodi-1.0.7.tar.gz" } ], "1.0.8": [ { "comment_text": "", "digests": { "md5": "177fb8af461f63167aa270c2be40554e", "sha256": "2bcdf428621c1e320db815489fe1bff1421e49f874338de8869b9e8ad2dbdcf1" }, "downloads": -1, "filename": "rodi-1.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "177fb8af461f63167aa270c2be40554e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9189, "upload_time": "2019-06-08T21:56:30", "url": "https://files.pythonhosted.org/packages/17/f1/03079c963764e931c73581c6e84e84b5f959f51262653628d8262baafd64/rodi-1.0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "001f459e16c794d57184b359de441040", "sha256": "9e8e15e6be27a4af4219fb8666916b2315fdd04f5e39bbf6dfffea86a281bad2" }, "downloads": -1, "filename": "rodi-1.0.8.tar.gz", "has_sig": false, "md5_digest": "001f459e16c794d57184b359de441040", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10793, "upload_time": "2019-06-08T21:56:31", "url": "https://files.pythonhosted.org/packages/33/b7/e0e5cfd55284bdbbd8b2aeecc36a049276ca26c3c500fea387808b07a452/rodi-1.0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "177fb8af461f63167aa270c2be40554e", "sha256": "2bcdf428621c1e320db815489fe1bff1421e49f874338de8869b9e8ad2dbdcf1" }, "downloads": -1, "filename": "rodi-1.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "177fb8af461f63167aa270c2be40554e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9189, "upload_time": "2019-06-08T21:56:30", "url": "https://files.pythonhosted.org/packages/17/f1/03079c963764e931c73581c6e84e84b5f959f51262653628d8262baafd64/rodi-1.0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "001f459e16c794d57184b359de441040", "sha256": "9e8e15e6be27a4af4219fb8666916b2315fdd04f5e39bbf6dfffea86a281bad2" }, "downloads": -1, "filename": "rodi-1.0.8.tar.gz", "has_sig": false, "md5_digest": "001f459e16c794d57184b359de441040", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10793, "upload_time": "2019-06-08T21:56:31", "url": "https://files.pythonhosted.org/packages/33/b7/e0e5cfd55284bdbbd8b2aeecc36a049276ca26c3c500fea387808b07a452/rodi-1.0.8.tar.gz" } ] }