{ "info": { "author": "Abel Andr\u00e9", "author_email": "abel.andre.87@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Philosophy\n----------\n\nInjecting class dependencies comes in 3 distinct ways :\n\n- *using class attributes (okay)*\n- using setters (better)\n- **using constructor (best)**\n\nWyre allows you to declare the dependencies of a given class using kwargs on a constructor. A single decorator ``@inject`` does the trick. This is particularly handy when your dependency tree grows large and deep. For example, this dependency chain : ``A < B < C < D < E``, would require you to write ``a = A(B(C(D(E()))))`` in order to create an instance of your class.\n\nUsing Wyre, you keep :\n\n- your production code clean by writing just ``A()`` since it works recursively\n- your unit tests simple : ``A(b=Mock())`` is all you need to mock out dependencies\n\nUsage\n-----\n\n.. code:: python\n\n class C:\n name = 'Bob'\n\n\n class B:\n @inject\n def __init__(self, other_dependency=C):\n self.c = other_dependency\n\n def say_hello(self):\n return 'Hello %s !' % self.c.name\n\n\n class A:\n @inject\n def __init__(self, dependency=B):\n self.b = dependency\n\n def greetings(self):\n return self.b.say_hello()\n\n a = A()\n a.greetings() # returns 'Hello Bob !'\n\nSince ``__init__`` is decorated with ``@inject``, ``B`` instance will be created and injected in ``A`` at instantiation time.\n\nLimitations\n-----------\n\nImportant notes on what ``@inject`` does :\n\n- If an instance of a dependency is provided in ``kwargs``, it will be preserved and not overridden by a new instance.\n- Circular dependencies are detected at instantiation time : an ``InjectionError`` will be raised.\n- You can only use it on ``__init__()``. If you decorate any other function : an ``InjectionError`` will be raised.\n- If no dependency is found among declared ``kwargs`` : an ``InjectionError`` will be raised.\n- Wyre is strongly opinionated about dependency injection. As a matter of fact, singletons are not even considered.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/blndr/wyre", "keywords": "dependency", "license": "", "maintainer": "", "maintainer_email": "", "name": "Wyre", "package_url": "https://pypi.org/project/Wyre/", "platform": "", "project_url": "https://pypi.org/project/Wyre/", "project_urls": { "Homepage": "https://gitlab.com/blndr/wyre" }, "release_url": "https://pypi.org/project/Wyre/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Lightweight dependency injection for pure OOP.", "version": "0.2.1" }, "last_serial": 3168943, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "1a0cd15fb078af84cfe1afbc1113f883", "sha256": "d00650aa10c95161342f5faad4c3e55c8dfaa1cc38ca1db59f8e7f4d651290df" }, "downloads": -1, "filename": "wyre-0.1.1.tar.gz", "has_sig": false, "md5_digest": "1a0cd15fb078af84cfe1afbc1113f883", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4637, "upload_time": "2017-09-11T21:34:15", "url": "https://files.pythonhosted.org/packages/97/35/21c669ea597e98855031fd5345311a98dd1442f21fa3d1108f909d65cbc6/wyre-0.1.1.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "fb8aa3ba07c4d14f8cfe12727230c71b", "sha256": "154f9ea45193729a020f0a2c03ef922fb912345073dc30e6a40ee5a540f05eea" }, "downloads": -1, "filename": "wyre-0.2.1.tar.gz", "has_sig": false, "md5_digest": "fb8aa3ba07c4d14f8cfe12727230c71b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4955, "upload_time": "2017-09-12T20:31:56", "url": "https://files.pythonhosted.org/packages/3a/1a/afcc4e737f363360f36cab9d73d7ede809e7261dd658de6facd05181b562/wyre-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fb8aa3ba07c4d14f8cfe12727230c71b", "sha256": "154f9ea45193729a020f0a2c03ef922fb912345073dc30e6a40ee5a540f05eea" }, "downloads": -1, "filename": "wyre-0.2.1.tar.gz", "has_sig": false, "md5_digest": "fb8aa3ba07c4d14f8cfe12727230c71b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4955, "upload_time": "2017-09-12T20:31:56", "url": "https://files.pythonhosted.org/packages/3a/1a/afcc4e737f363360f36cab9d73d7ede809e7261dd658de6facd05181b562/wyre-0.2.1.tar.gz" } ] }