{ "info": { "author": "Scott Pigman", "author_email": "scott.pigman@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development" ], "description": "checked(f)\n checked is a function decorator that uses function annotations as type declarations\n and verifies that the function has been passed, and is returning, the \n correct types of values. \n \n Yes, yes, I know, this is python and we're not supposed to have to have\n type checking. Before you pound your keyboard angrily telling me what an\n idiot I am, please at least read the \"Motivation\" section below. Thank you.\n \n SAMPLE USAGE:\n ------------\n \n @checked\n def function(parameter:) -> \n ....\n \n \"function\" may be a function, a method, or a generator*. \n \n * For generators the actual return type is type however \n @checked will check that the values yielded by the generator are \n of the specified type.\n \n may be any of the following:\n \n * a class or type object (int, str, MyClass, etc.)\n \n Example: \n ``def f( x:int ): # f() only accepts int``\n \n * A tuple (or any iterable) of type objects, indicating that the value may be an instance of \n any of those types.\n \n Example: \n ``def f( x: (int, str) ): # f() must return a str OR None``\n \n * The literal None, to indicate that only None is an acceptable value\n (usually used for declaring that a function does not return a value)\n \n Example: \n ``def f( x ) -> None: # f() has no return value``\n \n * A tuple (or any other iterable) containing type objects and the value None, indicating that\n the value may be any of the indicated types or the special value None.\n \n Example: \n ``def f( x ) -> (str, None) # f() must return a str or None``\n \n * Dict (or other mapping type) object which maps a collection type to an element type, \n { : }.\n \n This usage means that the function ruturns a collection of type \n (e.g. set, list, tuple, etc.), which contains only elements of type .\n \n Example: \n ``def f(x) -> {set:int}: # f() must return a set of integers``\n \n * A callable object which accepts one parameter and returns true or false. The callable \n object is treated as a pre-condition when annotating function parameters and a \n post-condition when annotating the return value. The value passed or returned will be \n passed to the callable and an error will be raised if the result is not true. \n \n Example \n ``def f( x: lambda x: x > 0 ): # f() only accepting values greater than zero``\n \n ``def g(x) -> lambda y: y >= 0: # g() must return a value >= 0``\n \n \n DEFAULTS, *ARG, AND **KWD\n --------------------------------------\n Parameters with default values, as well as *arg and **kwd arguments can also have\n their types declared:\n \n @checked\n def function(x:, y:=1, *args:, **kwds: A: # Error, when the annotation is processed, A has not yet been defined\n ...\n Solution:\n class A:\n @checked\n @classmethod\n def factory(cls, ...) -> type_proxy('A') # valid\n ...\n \n 2. Trying to create an annotation which refers to a class not yet defined, which itself uses an annotation\n that refers back to _this_ class (i.e. circular references). Because the two classes refer to each other\n the solution is not so simple as to just move the second class definition before the first.\n \n Example:\n class A:\n @checked\n def to_b(self) -> B : # Error: B not yet defined\n return B(self)\n \n class B:\n @checked\n def to_a(self) -> A : # A refers to B and B refers to A, so it doesn't matter\n return A(self) # which class is defined first, there's going to be an error.\n \n Solution:\n class A:\n @checked\n def to_b(self) -> type_proxy(\"B\") : # Fixed\n return B(self)\n \n class B:\n ...unchanged...", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "pycheck", "package_url": "https://pypi.org/project/pycheck/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pycheck/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/pycheck/0.1/", "requires_dist": null, "requires_python": null, "summary": "Type checking tools for debugging and developing Python code", "version": "0.1" }, "last_serial": 797041, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "9f116796c9e9c7f4d32da8fe02f67632", "sha256": "c5d9de6dc66d6ec36e6ce837665e784558df8609f1f6c00ff356cbf9ef5dcbad" }, "downloads": -1, "filename": "pycheck-0.1.tar.gz", "has_sig": false, "md5_digest": "9f116796c9e9c7f4d32da8fe02f67632", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12880, "upload_time": "2013-01-22T02:55:09", "url": "https://files.pythonhosted.org/packages/fe/b0/1791c383d7fd9d1d2ecdd7412c0ccdbf55e3c2b49591cd3eb220d7f849a7/pycheck-0.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "ce255377e487357e226d82bade6afb51", "sha256": "7998010296541a38bf05904628d937ec3b7918ce4319f0d99527bccf716dcdce" }, "downloads": -1, "filename": "pycheck-0.1.zip", "has_sig": false, "md5_digest": "ce255377e487357e226d82bade6afb51", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17202, "upload_time": "2013-01-22T02:55:11", "url": "https://files.pythonhosted.org/packages/10/48/d9d4c7cd178f0cde50992297cc05c901656eec459546fea302c856ed0bc0/pycheck-0.1.zip" } ], "0.1dev": [ { "comment_text": "", "digests": { "md5": "29fbadcf6bffc337a6071f6aeb11222b", "sha256": "23d44ee3da5f8c88babf0737ef7263bb7c8af51a45cc6431bb3167fb67f063a2" }, "downloads": -1, "filename": "pycheck-0.1dev.tar.gz", "has_sig": false, "md5_digest": "29fbadcf6bffc337a6071f6aeb11222b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7939, "upload_time": "2013-01-21T05:07:33", "url": "https://files.pythonhosted.org/packages/8e/2c/987f868932ca0d00eac1267c0953e48512c136f2f0589fea18fcf6b283e9/pycheck-0.1dev.tar.gz" }, { "comment_text": "", "digests": { "md5": "8955982bb3408279a1bdbd3483f32212", "sha256": "6152ffc3bdb359415c77ea71d55a6df70abee0f3323fda5246b5499e99b16471" }, "downloads": -1, "filename": "pycheck-0.1dev.zip", "has_sig": false, "md5_digest": "8955982bb3408279a1bdbd3483f32212", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9366, "upload_time": "2013-01-21T05:07:39", "url": "https://files.pythonhosted.org/packages/ee/34/3f4a6e3814eca304628c3c8fa1032c04eb1aa6f17928b42f322dccb21c02/pycheck-0.1dev.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9f116796c9e9c7f4d32da8fe02f67632", "sha256": "c5d9de6dc66d6ec36e6ce837665e784558df8609f1f6c00ff356cbf9ef5dcbad" }, "downloads": -1, "filename": "pycheck-0.1.tar.gz", "has_sig": false, "md5_digest": "9f116796c9e9c7f4d32da8fe02f67632", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12880, "upload_time": "2013-01-22T02:55:09", "url": "https://files.pythonhosted.org/packages/fe/b0/1791c383d7fd9d1d2ecdd7412c0ccdbf55e3c2b49591cd3eb220d7f849a7/pycheck-0.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "ce255377e487357e226d82bade6afb51", "sha256": "7998010296541a38bf05904628d937ec3b7918ce4319f0d99527bccf716dcdce" }, "downloads": -1, "filename": "pycheck-0.1.zip", "has_sig": false, "md5_digest": "ce255377e487357e226d82bade6afb51", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17202, "upload_time": "2013-01-22T02:55:11", "url": "https://files.pythonhosted.org/packages/10/48/d9d4c7cd178f0cde50992297cc05c901656eec459546fea302c856ed0bc0/pycheck-0.1.zip" } ] }