{
"info": {
"author": "Kenneth Knowles",
"author_email": "kenn.knowles@gmail.com",
"bugtrack_url": null,
"classifiers": [],
"description": "A Type Language for Python\n==========================\n\nhttps://github.com/kennknowles/python-typelanguage\n\nThis package provides a type language for communicating about Python\nprograms and values. Humans communicating to other humans, humans\ncommunicating to the computer, and even the computer communicating to\nhumans (via type inference and run-time contract checking).\n\nThis project has a \u201cduck-typed\u201d status: Whatever you can use it for, it\nis ready for :-)\n\nHere is a more concrete list of implemented and intended features:\n\n- *yes* - Definition of a type language.\n- *yes* - Parsing and printing.\n- *yes* - Monitoring of type adherence for monomorphic types.\n- *yes* - \u201cAny\u201d type for easily saying exactly where things get really\n dynamic.\n- *upcoming* - Monitoring of type adherence for polymorphic types.\n- *upcoming* - Generation of constraints between types in a program.\n- *upcoming* - Best-effort inference of suitable types.\n- *upcoming* - Refinement types with hybrid type checking.\n\nThe Types\n---------\n\nThis type language is built from the following concepts:\n\n- Named types: ``int``, ``long``, ``float``, ``complex``, ``str``,\n ``unicode``, ``file``, ``YourClassNameHere``, \u2026\n- List types: ``[int]``, ``[[long]]``, \u2026\n- Tuple types: ``(int, long)``, ``(float, (int, Regex))``, \u2026\n- Dictionary types: ``{string: float}``,\n ``{ (str, str) : [complex] }``, \u2026\n- Union types ``int|long|float``, ``str|file``, \u2026\n- The \u201cany\u201d type, ``??``, for when a value is too complex to describe\n in this language. May be an indication that a piece of code is\n metaprogramming or should be treated with gradual typing.\n- Function types:\n\n - ``str -> int``\n - ``(int) -> int``\n - ``(int, int) -> int``\n - ``( (int, int) ) -> int``\n - ``( str|file ) -> SomeClass``\n - ``(int, *[str]) -> [(str, int)]``\n - ``(int, *[int], **{int: str}) -> str``\n\n- Object types: ``object(self_type, field1: int, field2: str, ...)``\n- Polymorphic types (where ``~a``, ``~b``, ``~c`` range over any other\n type)\n\n - ``~a -> ~a``\n - ``[~a] -> [~a]``\n - ``( (~a, ~b) ) -> ~a``\n\nTypes as Contracts\n------------------\n\nThe module ``typelanguage.enforce`` contains functions for using these\ntypes as run-time monitors.\n\nApplied directly:\n\n::\n\n >>> check('{string: int}', {\"hello\" : \"there\"})\n\nMore interestingly, automatically protecting a function from bad input,\nfor example, putting better error checking on Python\u2019s\n``unicode``/``str`` interactions.\n\n::\n\n >>> '\\xa3'.encode('utf-8')\n ...\n UnicodeDecodeError: 'ascii' codec can't decode byte 0xa3 in position 0: ordinal not in range(128)\n\n >>> @guard('unicode -> str')\n ... def safe_encode(s):\n ... return s.encode('utf-8')\n\n >>> safe_encode(u'hello')\n 'hello'\n >>> safe_encode('\\xa3')\n TypeError: Type check failed: ? does not have type unicode\n\nEventually, the notion of *blame* may be usefully incorporated, for\npointing out which piece of code or agent in a distributed setting is\nresponsible for the undesirable value.\n\nType Inference\n--------------\n\nIn the spirit of Python and dynamic languages, type inference is\nbest-effort. It works like so:\n\n1. By traversing the code, we can discover a bunch of constraints\n between types in different bits.\n2. Some of these constraints are going to be very easy to solve, so we\n can just propagate the results.\n3. Some of these constraints are not going to be practical to try to\n solve, so we can just drop them or insert some enforcement code if we\n like.\n\nMore to explore\n---------------\n\nThere are many other projects that check contracts or types for Python\nin some way or another, but none makes communication their primary goal,\nwith the possible exception of pySonar. As such, they make different\ndesign choices. Some are research projects or prototypes \u2013 this is not.\nThis is a library meant for use.\n\n- `PEP 316 `_ (deferred)\n- `RPython `_ and\n `PyPy `_ (compilation-oriented)\n- `pySonar `_ and\n `mini-pysonar `_ (way cool)\n- `Pyntch `_\n- `typechecker `_\n- `pycontract `_\n- `python-dbc `_ and `one\n pyDBC `_ and `another\n pydbc `_ and `yet another\n pyDBC `_\n- `python-type-inference `_\n (no code, but has a great list of papers and even more tools)\n\nAnd since dynamic languages are much of a muchness, it is worthwhile\nseeing what is happening elsewhere, though again very few projects\nemphasize the types themselves as fun, interesting and useful, only that\nthe code has them.\n\n- `Contracts in\n Racket `_ and\n `Typed Racket `_\n- `Typescript `_ aka `a slightly\n gradually-typed\n Javascript `_\n and `Javascript++ `_ (sort of\n gradually-typed Javascript) and\n `javascript-contracts `_\n and `cerny `_\n- `Este `_ (statically-typed\n coffeescript) and\n `Uberscript `_\n (gradually-typed coffeescript) and\n `contracts.coffee `_\n- `Contracts.ruby `_\n\nI\u2019m omitting the billion typed languages that compile to Javascript\nbecause those are just typed languages compiler to the assembly language\nof the web.\n\nFinally, if you want to actually grok types, then contracts, then types\nand contracts together, then types and dynamic types together, then\n*polymorphic* type as contracts and dynamic types together, then type\ninference for such systems, try this chronological series of reading.\n\n- `*Types and Programming\n Languages* `_ by Benjamin\n Pierce.\n- `Contracts for higher-order\n functions `_\n by Robert Bruce Findler & Matthias Felleisen. ICFP 2002.\n- `Hybrid type\n checking `_ by\n Kenneth Knowles & Cormac Flanagan. TOPLAS 2010. (expanded and\n corrected from POPL 2006)\n- `Gradual typing for functional\n languages `_\n by Jeremy Siek & Walid Taha. Scheme workshop 2006.\n- `Gradual Typing for\n Objects `_ by Jeremy\n Siek and Walid Taha. ECOOP 2007.\n- `Type reconstruction for general refinement\n types `_ by\n Kenneth Knowles & Cormac Flanagan. ESOP 2007.\n- `Relationally-parametric polymorphic\n contracts `_\n by Arjun Guha, Jacob Matthews, Robert Bruce Findler, and Shriram\n Krishnamurthi. DLS 2007.\n- `Gradual typing with unification based\n inference `_ by Jeremy\n Siek and Manish Vachharajani. DLS 2008.\n- `Blame for\n all `_\n by Amal Ahmed, Robert Bruce Findler, Jacob Matthews, and Philip\n Wadler. STOP 2009.\n- `Always available static and dynamic\n feedback `_\n by Michael Bayne, Richard Cook, and Michael D. Ernst. ICSE 2011.\n- `The ins and outs of of gradual type\n inference `_ by Aseem\n Rastogi, Avik Chaudhuri, and Basil Hosmer. POPL 2012.\n\nContributors\n------------\n\n- `Kenn Knowles `_\n (`@kennknowles `_)\n\nCopyright and License\n---------------------\n\nCopyright 2012- Kenneth Knowles\n\nLicensed under the Apache License, Version 2.0 (the \u201cLicense\u201d); you may\nnot use this file except in compliance with the License. You may obtain\na copy of the License at\n\n::\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \u201cAS IS\u201d BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.",
"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/kennknowles/python-typelanguage",
"keywords": null,
"license": "Apache 2.0",
"maintainer": null,
"maintainer_email": null,
"name": "typelanguage",
"package_url": "https://pypi.org/project/typelanguage/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/typelanguage/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://github.com/kennknowles/python-typelanguage"
},
"release_url": "https://pypi.org/project/typelanguage/0.3/",
"requires_dist": null,
"requires_python": null,
"summary": "A type language for Python, including parsing, pretty-printing, type inference, type checking, and run-time contract enforcement.",
"version": "0.3"
},
"last_serial": 801152,
"releases": {
"0.1": [
{
"comment_text": "",
"digests": {
"md5": "5d7cd0519cf407bc2a118ecb59de2d04",
"sha256": "3d3af027d40fcc71885e907937d3fc2fe99d48d15bba48594e431af4c8a7e6d6"
},
"downloads": -1,
"filename": "typelanguage-0.1.tar.gz",
"has_sig": false,
"md5_digest": "5d7cd0519cf407bc2a118ecb59de2d04",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17496,
"upload_time": "2013-01-16T02:28:31",
"url": "https://files.pythonhosted.org/packages/99/ea/76f5a7ccdd7a134a11968315a4361b5a9f9308d9ee06cff77d7cb5ad0d58/typelanguage-0.1.tar.gz"
}
],
"0.2": [
{
"comment_text": "",
"digests": {
"md5": "ed74a49a95988e8ac5b1c44a8f0314a8",
"sha256": "45f21856dc5ba96aa8797a1a030cb9ba4805c6a1ac44945177444a110ec6fba6"
},
"downloads": -1,
"filename": "typelanguage-0.2.tar.gz",
"has_sig": false,
"md5_digest": "ed74a49a95988e8ac5b1c44a8f0314a8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17501,
"upload_time": "2013-01-16T02:32:11",
"url": "https://files.pythonhosted.org/packages/3f/15/c92df82bb2c4729f007c64861faff33f15ef6571a9c2b90ed81759c01be9/typelanguage-0.2.tar.gz"
}
],
"0.3": [
{
"comment_text": "",
"digests": {
"md5": "0d89ccf6867fde26dbe44e155171ee61",
"sha256": "ac86ab98ceed0392b3c631e1701dbb6702461e2bd69eea6eba22c94a490f2324"
},
"downloads": -1,
"filename": "typelanguage-0.3.tar.gz",
"has_sig": false,
"md5_digest": "0d89ccf6867fde26dbe44e155171ee61",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17456,
"upload_time": "2013-01-16T02:33:41",
"url": "https://files.pythonhosted.org/packages/0a/e1/135f46a1f1eb7441cf4bdba7d339b1e0d8218fd44d0fda6c8d5fb9f0af07/typelanguage-0.3.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "0d89ccf6867fde26dbe44e155171ee61",
"sha256": "ac86ab98ceed0392b3c631e1701dbb6702461e2bd69eea6eba22c94a490f2324"
},
"downloads": -1,
"filename": "typelanguage-0.3.tar.gz",
"has_sig": false,
"md5_digest": "0d89ccf6867fde26dbe44e155171ee61",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17456,
"upload_time": "2013-01-16T02:33:41",
"url": "https://files.pythonhosted.org/packages/0a/e1/135f46a1f1eb7441cf4bdba7d339b1e0d8218fd44d0fda6c8d5fb9f0af07/typelanguage-0.3.tar.gz"
}
]
}