{ "info": { "author": "Shoma Hosaka", "author_email": "shoma.h4a+pypi@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "This module provides dynamic type check mechanism.\n\nNormal Type Check:\n\n >>> from typechecker import typeinfo, list_, tuple_, has_attrs\n >>> @typeinfo(int, x=int, y=int)\n ... def add(x, y):\n ... return x + y\n >>> add(10, 20)\n 30\n >>> add('aa', 'bb')\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"typechecker/typeinfo.py\", line 113, in call\n _check_arg(f, assigned, types)\n File \"typechecker/typeinfo.py\", line 84, in _check_arg\n f.__name__))\n TypeError: In function add, argument \"y\" required \"int\". \"str\" found.\n\nTuple Type Check:\n\n >>> @typeinfo(int, val=tuple_(int, str))\n ... def test(val):\n ... return len(val)\n ...\n >>> test((19, 'aaa'))\n 2\n >>> test('aaa')\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"typechecker/typeinfo.py\", line 113, in call\n _check_arg(f, assigned, types)\n File \"typechecker/typeinfo.py\", line 84, in _check_arg\n f.__name__))\n TypeError: In function test, argument \"val\" required \"tuple[int, str]\". \"str\" found.\n\nList Type Check:\n\n >>> @typeinfo(int, val=list_(int))\n ... def test(val):\n ... return 10\n ...\n >>> test([1,2,3])\n 10\n >>> test([1,2,'aaa'])\n Traceback (most recent call last):\n File \"typechecker/typeinfo.py\", line 113, in call\n _check_arg(f, assigned, types)\n File \"typechecker/typeinfo.py\", line 84, in _check_arg\n f.__name__))\n TypeError: In function test, argument \"val\" required \"list[int]\". \"list\" found.\n\nComplex Type Check:\n \n >>> @typeinfo(int, val=tuple_(list_(int)))\n ... def test(val):\n ... return 10\n ...\n >>> test(([1],))\n 10\n >>> test((['aa'],))\n Traceback (most recent call last):\n File \"/usr/local/python2.7/lib/python2.7/doctest.py\", line 1254, in __run\n compileflags, 1) in test.globs\n File \"\", line 1, in \n test((['aa'],))\n File \"typechecker/typeinfo.py\", line 113, in call\n _check_arg(f, assigned, types)\n File \"typechecker/typeinfo.py\", line 84, in _check_arg\n f.__name__))\n TypeError: In function test, argument \"val\" required \"tuple[list[int]]\". \"tuple\" found.\n\n\n Structural subtyping:\n\n >>> @typeinfo(int, f=Callable)\n ... def test(f):\n ... return 10\n ...\n >>> test(map)\n 10\n >>> test(1)\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"typechecker/typeinfo.py\", line 113, in call\n _check_arg(f, assigned, types)\n File \"typechecker/typeinfo.py\", line 84, in _check_arg\n f.__name__))\n TypeError: In function test, argument \"f\" required \"hasattr[__call__]\". \"int\" found.\n\n\nAnd check:\n\n >>> @typeinfo(int, f=and_(Callable, ContextManager))\n ... def test(f):\n ... return 10\n ...\n >>> test(file)\n 10\n >>> test(map)\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"typechecker/typeinfo.py\", line 113, in call\n _check_arg(f, assigned, types)\n File \"typechecker/typeinfo.py\", line 84, in _check_arg\n f.__name__))\n TypeError: In function test, argument \"f\" required \"And[hasattr[__call__], hasattr[__enter__, __exit__]]\". \"builtin_function_or_method\" found.", "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/shomah4a/typechecker", "keywords": null, "license": "LGPL", "maintainer": null, "maintainer_email": null, "name": "typechecker", "package_url": "https://pypi.org/project/typechecker/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/typechecker/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/shomah4a/typechecker" }, "release_url": "https://pypi.org/project/typechecker/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "This module provides dynamic type check mechanism.", "version": "0.1.1" }, "last_serial": 801150, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "7b4c2b672867c9eefdc540f1d33da7a2", "sha256": "25283e4d0e3a0fe0670b432532da305ff1e5096c01590241b7b4739f7e6f49d2" }, "downloads": -1, "filename": "typechecker-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7b4c2b672867c9eefdc540f1d33da7a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3218, "upload_time": "2011-07-09T05:46:20", "url": "https://files.pythonhosted.org/packages/24/eb/871c7e06ca68fa308b25008f45b1cd636a22518b5ee3a5fa4e39acea9cd4/typechecker-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "af98e7802513bbde80cb437d3af2e736", "sha256": "6c27f50460d4839c9f684495f246ab4c483224e1e53a021b0d852bcf1e1695fa" }, "downloads": -1, "filename": "typechecker-0.1.1.tar.gz", "has_sig": false, "md5_digest": "af98e7802513bbde80cb437d3af2e736", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4079, "upload_time": "2011-07-09T08:22:36", "url": "https://files.pythonhosted.org/packages/53/a0/b31fd6f7200e5306ca2a36457c64ce34b0681df7d80234dda12e49f6b361/typechecker-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "af98e7802513bbde80cb437d3af2e736", "sha256": "6c27f50460d4839c9f684495f246ab4c483224e1e53a021b0d852bcf1e1695fa" }, "downloads": -1, "filename": "typechecker-0.1.1.tar.gz", "has_sig": false, "md5_digest": "af98e7802513bbde80cb437d3af2e736", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4079, "upload_time": "2011-07-09T08:22:36", "url": "https://files.pythonhosted.org/packages/53/a0/b31fd6f7200e5306ca2a36457c64ce34b0681df7d80234dda12e49f6b361/typechecker-0.1.1.tar.gz" } ] }