{ "info": { "author": "Dmitry Dvoinikov, Lutz Prechelt", "author_email": "prechelt@inf.fu-berlin.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Documentation", "Topic :: Software Development :: Quality Assurance" ], "description": "A decorator for functions, ``@tc.typecheck``, to be used together with\nPython3 annotations on function parameters and function results.\nThe decorator will perform dynamic argument type checking for every call to the function.\n\n::\n\n @tc.typecheck\n def foo1(a:int, b=None, c:str=\"mydefault\") -> bool :\n print(a, b, c)\n return b is not None and a != b\n\nThe parts ``:int``, ``:str``, and ``-> bool`` are annotations.\nThis is a syntactic feature introduced in Python 3 where ``:`` (for parameters)\nand ``->`` (for results) are delimiters and the rest can be\nan arbitrary expression.\nIt is important to understand that, as such,\n*annotations do not have any semantics whatsoever*.\nThere must be explicit Python code somewhere\nthat looks at them and does something in order to give them a meaning.\n\nThe ``@tc.typecheck`` decorator gives the above annotations the following meaning:\n``foo1``'s argument ``a`` must have type ``int``,\n``b`` has no annotation and can have any type whatsoever, it will not be checked,\n``c`` must have type string,\nand the function's result must be either\n``True`` (not ``17`` or ``\"yes\"`` or ``[3,7,44]`` or some such) or\n``False`` (not ``0`` or ``None`` or ``[]`` or some such).\n\nIf any argument has the wrong type, a ``TypeCheckError`` exception will be raised.\nClass types, collection types, fixed-length collections and\ntype predicates can be annotated as well.\nHere is a more complex example:\n\n::\n\n import typecheck as tc\n\n @tc.typecheck\n def foo2(record:(int,int,bool), rgb:tc.re(\"^[rgb]$\")) -> tc.any(int,float) :\n a = record[0]; b = record[1]\n return a/b if (a/b == float(a)/b) else float(a)/b\n\n foo2((4,10,True), \"r\") # OK\n foo2([4,10,True], \"g\") # OK: list is acceptable in place of tuple\n foo2((4,10,1), \"rg\") # Wrong: 1 is not a bool, string is too long\n foo2(None, \"R\") # Wrong: None is no tuple, string has illegal character\n\nThese annotations mean that ``record`` is a 3-tuple of two ints and\nan actual bool and ``rgb`` is a one-character string that is\neither \"r\" or \"g\" or \"b\" by virtue of a regular expression test.\nThe result will be a number that can be either int or float.\n\nOther kinds of annotations:\n\n- ``tc.optional(int)`` will allow int and None,\n- ``tc.enum(1, 2.0, \"three\")`` allows to define ad-hoc enumeration types,\n- ``tc.map_of(str, tc.list_of(Person))`` describes dictionaries where all\n keys are strings and all values are homogeneous lists of Persons,\n- and so on.\n\nFind the documentation at\nhttps://github.com/prechelt/typecheck-decorator", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/prechelt/typecheck-decorator-stable", "keywords": "type-checking", "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "typecheck-decorator-stable", "package_url": "https://pypi.org/project/typecheck-decorator-stable/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/typecheck-decorator-stable/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/prechelt/typecheck-decorator-stable" }, "release_url": "https://pypi.org/project/typecheck-decorator-stable/1.0/", "requires_dist": null, "requires_python": null, "summary": "flexible explicit type checking of function arguments (Python3-only)", "version": "1.0" }, "last_serial": 1488487, "releases": { "1.0": [ { "comment_text": "built for Darwin-14.1.0", "digests": { "md5": "b3048a8bb4408c119ddc47d9992507b6", "sha256": "f83b18911dddd04f6d6656113299488c3f26aeeccec0bf28d347f2f3db1bd2d1" }, "downloads": -1, "filename": "typecheck-decorator-stable-1.0.macosx-10.10-x86_64.tar.gz", "has_sig": false, "md5_digest": "b3048a8bb4408c119ddc47d9992507b6", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 34062, "upload_time": "2015-04-02T17:50:31", "url": "https://files.pythonhosted.org/packages/db/ed/23df1afb8c75c6927552da4402da6599c16e1ed6f22b1a1aca3a4d894c7f/typecheck-decorator-stable-1.0.macosx-10.10-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "92240f20ad47e1539755f533bd7b8854", "sha256": "677ce713f902612c6a8c9d8afa15541f1095efe8dc4b29ae56ce238af0e9a491" }, "downloads": -1, "filename": "typecheck_decorator_stable-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "92240f20ad47e1539755f533bd7b8854", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 15987, "upload_time": "2015-04-02T17:51:08", "url": "https://files.pythonhosted.org/packages/46/15/5a5e3a83dcaf31ccf4b518d59174b408cd94808d7345d3234f744cd8613b/typecheck_decorator_stable-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4c210772810ea7e0d0a58c4f5e1aa088", "sha256": "d8145b7494679e8fe9e2fddddd5c8feab268eaa84366f5acab4ab6092c52bd71" }, "downloads": -1, "filename": "typecheck-decorator-stable-1.0.tar.gz", "has_sig": false, "md5_digest": "4c210772810ea7e0d0a58c4f5e1aa088", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15619, "upload_time": "2015-04-02T17:50:23", "url": "https://files.pythonhosted.org/packages/ba/d6/9bc4f046676c454f55c84c3f1fe643795b8fda2e78a7ea1904f3a8441180/typecheck-decorator-stable-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "built for Darwin-14.1.0", "digests": { "md5": "b3048a8bb4408c119ddc47d9992507b6", "sha256": "f83b18911dddd04f6d6656113299488c3f26aeeccec0bf28d347f2f3db1bd2d1" }, "downloads": -1, "filename": "typecheck-decorator-stable-1.0.macosx-10.10-x86_64.tar.gz", "has_sig": false, "md5_digest": "b3048a8bb4408c119ddc47d9992507b6", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 34062, "upload_time": "2015-04-02T17:50:31", "url": "https://files.pythonhosted.org/packages/db/ed/23df1afb8c75c6927552da4402da6599c16e1ed6f22b1a1aca3a4d894c7f/typecheck-decorator-stable-1.0.macosx-10.10-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "92240f20ad47e1539755f533bd7b8854", "sha256": "677ce713f902612c6a8c9d8afa15541f1095efe8dc4b29ae56ce238af0e9a491" }, "downloads": -1, "filename": "typecheck_decorator_stable-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "92240f20ad47e1539755f533bd7b8854", "packagetype": "bdist_wheel", "python_version": "3.4", "requires_python": null, "size": 15987, "upload_time": "2015-04-02T17:51:08", "url": "https://files.pythonhosted.org/packages/46/15/5a5e3a83dcaf31ccf4b518d59174b408cd94808d7345d3234f744cd8613b/typecheck_decorator_stable-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4c210772810ea7e0d0a58c4f5e1aa088", "sha256": "d8145b7494679e8fe9e2fddddd5c8feab268eaa84366f5acab4ab6092c52bd71" }, "downloads": -1, "filename": "typecheck-decorator-stable-1.0.tar.gz", "has_sig": false, "md5_digest": "4c210772810ea7e0d0a58c4f5e1aa088", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15619, "upload_time": "2015-04-02T17:50:23", "url": "https://files.pythonhosted.org/packages/ba/d6/9bc4f046676c454f55c84c3f1fe643795b8fda2e78a7ea1904f3a8441180/typecheck-decorator-stable-1.0.tar.gz" } ] }