{ "info": { "author": "Fredrik Gjertsen", "author_email": "f.gjertsen@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Utilities" ], "description": "Type corrector\r\n==============\r\n\r\nImportant\r\n----------\r\n\r\nThis project has merged with typesys and will no longer be maintained.\r\nTypesys can be found `on github `_\r\nor `pypi `_ or it can be installed with pip install typesys.\r\n\r\nIntro\r\n-----\r\n\r\nType corrector is module that contains the decorator type_corrector.\r\nThis decorator lets the user specify what types the \r\narguments to a function should have. It's not 100% safe to use as it\r\nmight result in a ValueError or TypeError if the user is not careful enough.\r\nThe motivation behing this module was to find a way that makes it easier\r\nfor the programmer to see what types the arguments should be, and at \r\nthe same time allow some margin of error.\r\nI'm not sure if this is a good idea, or if it's a good approach. It was\r\nmostly developed for fun while playing around with decorators.\r\n\r\nInstallation\r\n------------\r\n\r\npip install typecorrector\r\n\r\n\r\nUsage\r\n-----\r\nFirst import type_corrector from the typecorrector module:\r\n\r\n.. code:: python\r\n\r\n from typecorrector import type_corrector\r\n\r\nThen you can decorate your functions with type_corrector\r\n\r\n.. code:: python\r\n\r\n @type_corrector(int, int)\r\n def add(x,y):\r\n return x+y\r\n\r\n \r\n @type_corrector(float, float)\r\n def div(x,y):\r\n return x/y\r\n \r\n\r\nA call to add(1,'2') will cast '2' to an int, since that is what we\r\nspecified as the type of the second paramater in the decorator.\r\nWe can also call div as div('10', '3'), and div will return 3.3333333333333335\r\nas expected.\r\n\r\nThis decorator also works with \\*args and \\*\\*kwargs\r\n\r\n.. code:: python\r\n\r\n @type_corrector(int)\r\n def mult(*numbers):\r\n result = 1\r\n for num in numbers:\r\n result *= num\r\n return result\r\n\r\n\r\n @type_corrector(int)\r\n def kw_mult(**kwargs):\r\n first = kwargs.get('first')\r\n second = kwargs.get('second')\r\n third = kwargs.get('third')\r\n return first * second * third\r\n\r\n\r\nThis allows us to call the functions like this:\r\n\r\n- mult('2', '3', '4') \r\n- kw_mult(first='2', second='3', third='4')\r\n\r\nWhen looking at the function definitions of add, mult and kw_mult we can easily\r\nsee that the arguments are supposed to be integers.\r\nBy decorating the functions like this it should be a clear\r\nhint what types we want the parameters to be passed in as, even though it \r\nallows some margin of error.\r\n\r\n\r\nKnown issues\r\n------------\r\nWhen calling help on a decorated function the parameters are not shown\r\ncorrectly, instead it will just say (\\*args, \\*\\*kwargs)\r\nAlso, when using inspect to get the argument specification with\r\ninspect.getargspec or getting the source code from inspect.getsourcelines\r\nit will fail.\r\nThanks to the functools.wraps decorator the docstring of a wrapped function\r\nwill still be shown correctly.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/fredgj/typecorrector", "keywords": "types,type hints,type hinting", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "typecorrector", "package_url": "https://pypi.org/project/typecorrector/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/typecorrector/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/fredgj/typecorrector" }, "release_url": "https://pypi.org/project/typecorrector/0.2.2/", "requires_dist": null, "requires_python": null, "summary": "A decorator meant to give type hints about function parameters as well as allow a margin of error", "version": "0.2.2" }, "last_serial": 1658591, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "dcc5b0f45d789cd1b41bb2b584010a59", "sha256": "c001deb087a6a922ff6e4942dbcb38a2a95ef08ae2362bb23b39a25fee86000f" }, "downloads": -1, "filename": "typecorrector-0.1.0.tar.gz", "has_sig": false, "md5_digest": "dcc5b0f45d789cd1b41bb2b584010a59", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3332, "upload_time": "2015-07-29T23:31:03", "url": "https://files.pythonhosted.org/packages/56/b9/63934229535a10a27bab44634f5f34ddb91914dd413a2605d953085c8f24/typecorrector-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "97dde745c909feb09cc981e3bb85f9f0", "sha256": "526c5045726a5a80cb976ed4fb80a6d8d76c52f2e06772457868a1ef01e9a234" }, "downloads": -1, "filename": "typecorrector-0.2.0.tar.gz", "has_sig": false, "md5_digest": "97dde745c909feb09cc981e3bb85f9f0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3272, "upload_time": "2015-07-29T23:43:44", "url": "https://files.pythonhosted.org/packages/41/99/4fccb1aa361de179dc3cbbe054eaaaa60dfa524e6ab8519835c913a34a3c/typecorrector-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "cd93098efb53cd4acbd5ca8b4ea1d846", "sha256": "6cdd3d46b169f66f74b176bd8bbf99218ded8759d169b8f7c22131d192894568" }, "downloads": -1, "filename": "typecorrector-0.2.1.tar.gz", "has_sig": false, "md5_digest": "cd93098efb53cd4acbd5ca8b4ea1d846", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3274, "upload_time": "2015-07-29T23:47:32", "url": "https://files.pythonhosted.org/packages/92/ff/c7aa31d47ff56b1536dedbe462d1ee29456041bc09de6d2d1816cf6cf93f/typecorrector-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "5459e86432b924b744fcfa5e2a7de76f", "sha256": "7adc0294b5da46d5548d0f6303bcbc11178ff885406bdfd64f19cdbd861c1b6f" }, "downloads": -1, "filename": "typecorrector-0.2.2.tar.gz", "has_sig": false, "md5_digest": "5459e86432b924b744fcfa5e2a7de76f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3260, "upload_time": "2015-07-30T02:10:21", "url": "https://files.pythonhosted.org/packages/4d/bd/0eebd2299717c74644ddcbe49250611019a30f02aafd933bc2efd477f1aa/typecorrector-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5459e86432b924b744fcfa5e2a7de76f", "sha256": "7adc0294b5da46d5548d0f6303bcbc11178ff885406bdfd64f19cdbd861c1b6f" }, "downloads": -1, "filename": "typecorrector-0.2.2.tar.gz", "has_sig": false, "md5_digest": "5459e86432b924b744fcfa5e2a7de76f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3260, "upload_time": "2015-07-30T02:10:21", "url": "https://files.pythonhosted.org/packages/4d/bd/0eebd2299717c74644ddcbe49250611019a30f02aafd933bc2efd477f1aa/typecorrector-0.2.2.tar.gz" } ] }