{ "info": { "author": "Stanislav Lobanov", "author_email": "n10101010@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "Wint - dependency injection with type hints.\n============================================\n\n[![Build Status](https://travis-ci.org/asyncee/wint.svg?branch=master)](https://travis-ci.org/asyncee/wint)\n[![Coverage Status](https://coveralls.io/repos/github/asyncee/wint/badge.svg?branch=master)](https://coveralls.io/github/asyncee/wint?branch=master)\n\nIntro\n-----\n\nWint is a lightweight library that implements dependency injection via type hinting.\n\nInstallation\n------------\n\nJust use pip:\n```\n$ pip install wint\n```\n\nHow it works\n------------\n\nThere are a ton of approaches to DI, and this library implements only property injection.\n\nWhen ``autowired`` decorator is applied then class is inspected for all\nannotated properties. If property has no value, then it is replaced with ``DependencyDescriptor``.\n\nDependency is resolved when attribute is accessed on instantiated class instance.\n\nThis behaviour allows to resolve dependencies in lazy manner with the downside of a side effect \u2014 instance\nreceives a descriptor property that was not existed earlier.\n\nExample\n-------\n\n```python\nfrom wint import autowired, ContainerProvider\n\n\nclass Printer:\n \"\"\"Abstract class for printing messages.\"\"\"\n\n def print(self, message):\n raise NotImplementedError\n\n\nclass RealPrinter(Printer):\n \"\"\"Implementation of `Printer` which uses `print` to output messages.\"\"\"\n\n def print(self, message):\n print(message)\n\n\n@autowired()\nclass PrintService:\n # RealPrinter will be automatically injected on property access.\n printer: Printer\n\n def run(self, msg):\n self.printer.print(f\"{msg}, i'm running!\")\n\n\nif __name__ == \"__main__\":\n container = ContainerProvider.get()\n # Register RealPrinter as singleton implementation of Printer.\n container.register(Printer, RealPrinter())\n\n PrintService().run('hey')\n```\n\n```bash\n$ python example.py\nhey, i'm running!\n```\n\nNotes\n-----\nThis library is built on [punq](https://github.com/bobthemighty/punq)\n(MIT License) and uses it's vendored version.\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/asyncee/wint", "keywords": "dependency injection,type hinting,wint", "license": "MIT", "maintainer": "Stanislav Lobanov", "maintainer_email": "n10101010@gmail.com", "name": "wint", "package_url": "https://pypi.org/project/wint/", "platform": "", "project_url": "https://pypi.org/project/wint/", "project_urls": { "Homepage": "https://github.com/asyncee/wint" }, "release_url": "https://pypi.org/project/wint/0.2.0/", "requires_dist": null, "requires_python": ">=3.6", "summary": "Dependency injection with type hints", "version": "0.2.0" }, "last_serial": 4078625, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "0e914d873949b38a9d27cba2958251b6", "sha256": "ee04f2196659226e53e35f56f55250c8802edee23590081fcbdef8d0abd13348" }, "downloads": -1, "filename": "wint-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "0e914d873949b38a9d27cba2958251b6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 23433, "upload_time": "2018-07-10T19:23:07", "url": "https://files.pythonhosted.org/packages/12/3e/a884d1ccc534277ab53ea0de4bce3508e5f40ff7d192f97fd0c4b8608cf4/wint-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4dea8428f22868d3660f256676f4c84c", "sha256": "2d66fd301b0175e8df43c5eccc21c7082fea24195e978dda332cda2ea9cefd94" }, "downloads": -1, "filename": "wint-0.1.0.tar.gz", "has_sig": false, "md5_digest": "4dea8428f22868d3660f256676f4c84c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5395, "upload_time": "2018-07-10T19:23:09", "url": "https://files.pythonhosted.org/packages/77/de/a2b22aa12e45af093ebda55ebe153e5d894a66633e1beee0aeb74bc85916/wint-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "7554c9762c43231d3032324d369fc637", "sha256": "9a9184eece1fa3438fa86600d5dc3ecfb0ea8c54f41627b5914e3191fd316ffb" }, "downloads": -1, "filename": "wint-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7554c9762c43231d3032324d369fc637", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 23644, "upload_time": "2018-07-18T15:34:26", "url": "https://files.pythonhosted.org/packages/c8/b9/81aab1d9fe2e405b51c25db5e5a5c9c8e5b701008f9c7055711126668706/wint-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a0e5b33f9bfde863dd9f3fe3cf6ccac7", "sha256": "96b5f93ea7aa2d01e47ad3e35144d0aaa913278507b1b059b007826f77f7f4dd" }, "downloads": -1, "filename": "wint-0.2.0.tar.gz", "has_sig": false, "md5_digest": "a0e5b33f9bfde863dd9f3fe3cf6ccac7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 6375, "upload_time": "2018-07-18T15:34:28", "url": "https://files.pythonhosted.org/packages/76/1a/5612341055155268a97ca8f0be196e1d21d152c2ebc4c16b1788213fe929/wint-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7554c9762c43231d3032324d369fc637", "sha256": "9a9184eece1fa3438fa86600d5dc3ecfb0ea8c54f41627b5914e3191fd316ffb" }, "downloads": -1, "filename": "wint-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "7554c9762c43231d3032324d369fc637", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 23644, "upload_time": "2018-07-18T15:34:26", "url": "https://files.pythonhosted.org/packages/c8/b9/81aab1d9fe2e405b51c25db5e5a5c9c8e5b701008f9c7055711126668706/wint-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a0e5b33f9bfde863dd9f3fe3cf6ccac7", "sha256": "96b5f93ea7aa2d01e47ad3e35144d0aaa913278507b1b059b007826f77f7f4dd" }, "downloads": -1, "filename": "wint-0.2.0.tar.gz", "has_sig": false, "md5_digest": "a0e5b33f9bfde863dd9f3fe3cf6ccac7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 6375, "upload_time": "2018-07-18T15:34:28", "url": "https://files.pythonhosted.org/packages/76/1a/5612341055155268a97ca8f0be196e1d21d152c2ebc4c16b1788213fe929/wint-0.2.0.tar.gz" } ] }