{ "info": { "author": "", "author_email": "lukasz@langa.pl", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Quality Assurance" ], "description": "# retype\n\n[![Build Status](https://dev.azure.com/ambv/retype/_apis/build/status/ambv.retype?branchName=master)](https://dev.azure.com/ambv/retype/_build/latest?definitionId=1&branchName=master)\n\nRe-apply type annotations from .pyi stubs to your codebase.\n\n## Usage\n\n```\nUsage: retype [OPTIONS] [SRC]...\n\n Re-apply type annotations from .pyi stubs to your codebase.\n\nOptions:\n -p, --pyi-dir DIRECTORY Where to find .pyi stubs. [default: types]\n -t, --target-dir DIRECTORY Where to write annotated sources. [default:\n typed-src]\n -i, --incremental Allow for missing type annotations in both stubs\n and the source.\n -q, --quiet Don't emit warnings, just errors.\n -a, --replace-any Allow replacing Any annotations.\n --hg Post-process files to preserve implicit byte\n literals.\n --traceback Show a Python traceback on error.\n --version Show the version and exit.\n --help Show this message and exit.\n```\n\nWhen you run `retype`, it goes through all files you passed as SRC,\nfinds the corresponding .pyi files in the `types/` directory, and\nre-applies typing annotations from .pyi to the sources, using the\nPython 3 function and variable annotation syntax. The resulting\ncombined sources are saved in `typed-src/`.\n\nYou can also pass directories as sources, in which case `retype` will\nlook for .py files in them recursively.\n\nIt's smart enough to do the following:\n\n* reapply typing imports\n* reapply function argument annotations\n* reapply function return value annotations\n* reapply method argument and return value annotations\n* reapply function-level variable annotations\n* reapply module-level name annotations\n* reapply module-level type aliases\n* reapply class-level field annotations\n* reapply instance-level field annotations\n* validate existing source annotations against the .pyi file\n* validate source function signatures against the .pyi file\n* read function signature type comments in .pyi files\n* read variable type comments in .pyi files\n* consider existing source type comments as annotations\n* remove duplicate type comments from source when annotations are applied\n* normalize remaining type comments in the source to annotations; this\n is done even if the corresponding .pyi file is missing\n\n\n## List of things to be done\n\n* [ ] add a --backward option to output type comments instead of annotations\n* [ ] handle if sys.version_info and sys.platform checks in stubs\n\n\n## Design principles\n\n* it's okay for a given .pyi file to be incomplete (gradual typing,\n baby!)\n* it's okay for functions and classes to be out of order in .pyi files\n and the source\n* it's an **error** for a function or class to be missing in the source\n* it's an **error** for a function's signature to be incompatible\n between the .pyi file and the source\n* it's an **error** for an annotation in the source to be incompatible\n with the .pyi file\n\n\n## Known limitations\n\n* Line numbers in the annotated source will no longer match original\n source code; this is because re-application of types requires copying\n typing imports and alias definitions from the .pyi file.\n* While formatting of the original source will be preserved, formatting\n of the applied annotations might differ from the formatting in .pyi\n files.\n* The source where type annotations get re-applied cannot use the\n legacy `print` statement; that wouldn't work at runtime.\n* Class attribute annotations in `__init__()` methods are moved verbatim\n to the respective `__init__()` method in the implementation. They are\n never translated into class-level attribute annotations, so if that\n method is missing, the translation will fail. Similarly, class-level\n attribute annotations are never applied to `__init__()` methods.\n* Forward references in .pyi files will only be properly resolved for\n type aliases and type vars (by inserting them right before they're\n used in the source). Other forms of forward references will not work\n in the source code due to out-of-order class and function definitions.\n Modify your .pyi files to use strings. `retype` will not\n automatically discover failing forward references and stringify them.\n* Local variable annotations present in the .pyi file are transferred to\n the body level of the given function in the source. In other words,\n if the source defines a variable within a loop or a conditional\n statement branch, `retype` will create an value-less variable\n annotation at the beginning of the function. Use a broad type and\n constrain types in relevant code paths using `assert isinstance()`\n checks.\n* Because of the above, existing source variable annotations and type\n comments buried in conditionals and loops will not be deduplicated\n (and `mypy` will complain that a name was already defined).\n* An async function in the stub will match a regular function of the\n same name in the same scope and vice versa. This is to enable\n annotating async functions spelled with `@asyncio.coroutine`.\n\n\n## Tests\n\nJust run:\n\n```\ntox\n```\n\n## OMG, this is Python 3 only!\n\nRelax, you can run *retype* **as a tool** perfectly fine under Python\n3.6+ even if you want to analyze Python 2 code. This way you'll be able\nto parse all of the new syntax supported on Python 3 but also\n*effectively all* the Python 2 syntax at the same time.\n\nBy making the code exclusively Python 3.6+, I'm able to focus on the\nquality of the checks and re-use all the nice features of the new\nreleases (check out [pathlib](docs.python.org/3/library/pathlib.html)\nor f-strings) instead of wasting cycles on Unicode compatibility, etc.\n\nNote: to retype modules using f-strings you need to run on Python 3.6.2+\ndue to [bpo-23894](http://bugs.python.org/issue23894).\n\n## License\n\nMIT\n\n\n## Change Log\n\n### next\n\n* add a module entry-point, now you can call it via ``python -m retype``\n* automatically all files excluded by ``.gitignore`` on merge of folders\n* support for ``ast3.num``\n* fix a bug that meant the merge was not recursive in paths\n* use `setup.cfg` based packaging configuration\n* add PEP-517/8 declaration via `pyproject.toml`\n* include license in both wheel and sdist\n* this projects code base is now formatted with *black*, import ordered via\n *isort*, and uses Azure Pipelines instead of Travis (also testing on Windows\n and macOs)\n\n### 17.12.0\n\n* support --replace-any to allow replacing pre-existing `Any` annotations\n without raising errors\n\n* bugfix: don't re-apply `# type: ignore` as an annotation if followed\n by another comment. Original patch by Shannon Zhu.\n\n### 17.6.3\n\n* bugfix: don't try to re-apply `# type: ignore` as a function annotation\n\n* bugfix: support arbitrary source file encodings, patch by Michael Overmeyer.\n\n* bugfix: support missing newlines at the end of the file, patch by Michael\n Overmeyer.\n\n* bugfix: in --incremental, format default values according to PEP 8\n (no spaces around the = sign if the type is missing)\n\n### 17.6.2\n\n* bugfix: --incremental didn't work with multiple arguments before\n\n### 17.6.1\n\n* support --incremental stub application (i.e. allow for both stubs and the\n source to be missing annotations for some arguments and/or return value)\n\n### 17.6.0\n\n* support async functions\n\n* support --traceback for getting more information about internal errors\n\n### 17.4.0\n\n* first published version\n\n* date-versioned\n\n\n## Authors\n\nGlued together by [\u0141ukasz Langa](mailto:lukasz@langa.pl). Multiple\nimprovements by [Michael Overmeyer](mailto:m.overmeyer@yahoo.ca) and\n[Bernat Gabor](mailto:gaborjbernat@gmail.com).\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ambv/retype", "keywords": "mypy typing typehints type hints pep484 pyi stubs", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "retype", "package_url": "https://pypi.org/project/retype/", "platform": "any", "project_url": "https://pypi.org/project/retype/", "project_urls": { "Homepage": "https://github.com/ambv/retype", "Source": "https://github.com/ambv/retype", "Tracker": "https://github.com/ambv/retype/issues" }, "release_url": "https://pypi.org/project/retype/19.9.0/", "requires_dist": [ "click", "typed-ast", "pathspec (<1,>=0.5.9)", "pytest (<5,>=3.0.0) ; extra == 'testing'", "pytest-cov (<3,>=2.5.1) ; extra == 'testing'" ], "requires_python": ">=3.6", "summary": "re-apply types from .pyi stub files to your codebase", "version": "19.9.0" }, "last_serial": 5825031, "releases": { "17.12.0": [ { "comment_text": "", "digests": { "md5": "e99b4729dcb715f6a4e900e4b80f0b0c", "sha256": "33cfb36601bfeb355924731d8db78fa82f3f12eb37e87236e9179d81aba97740" }, "downloads": -1, "filename": "retype-17.12.0-py3-none-any.whl", "has_sig": true, "md5_digest": "e99b4729dcb715f6a4e900e4b80f0b0c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 25059, "upload_time": "2017-12-04T21:16:30", "url": "https://files.pythonhosted.org/packages/a8/d1/7170691acee9757d9e629ff7aa448a93c37b6e6fcf9bbfad26ed7fecbfc7/retype-17.12.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a4f0d501b3258d3d67a40559fc5d859f", "sha256": "b64b767befbe6f5fd918603ab7d6bbff07fc4c431bae2f471e195677a0c9b327" }, "downloads": -1, "filename": "retype-17.12.0.tar.gz", "has_sig": true, "md5_digest": "a4f0d501b3258d3d67a40559fc5d859f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31934, "upload_time": "2017-12-04T21:16:32", "url": "https://files.pythonhosted.org/packages/6e/da/ca9f5560f051d2ed79a52de1170903e3ff8ad011cff56c65abfcff38d372/retype-17.12.0.tar.gz" } ], "17.4.0": [ { "comment_text": "", "digests": { "md5": "80781af8d400c59bc3364e5e692bd369", "sha256": "99178bc4871ac2ea885c73377274421dae979128fa20b1f75142620a2a6d6692" }, "downloads": -1, "filename": "retype-17.4.0.tar.gz", "has_sig": true, "md5_digest": "80781af8d400c59bc3364e5e692bd369", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24321, "upload_time": "2017-04-14T01:20:37", "url": "https://files.pythonhosted.org/packages/c6/a4/61878edd40dc0386fbd47ae31f4d4f83eb5ce345da9ed73703d5ece91b71/retype-17.4.0.tar.gz" } ], "17.6.0": [ { "comment_text": "", "digests": { "md5": "7a75c71f3f21ad572913ddd210d5c3c8", "sha256": "0480d5ec4c277613f03faea35c5f5db9dd03c49d19e1ab30f0d44655612a3192" }, "downloads": -1, "filename": "retype-17.6.0-py3-none-any.whl", "has_sig": true, "md5_digest": "7a75c71f3f21ad572913ddd210d5c3c8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 23346, "upload_time": "2017-06-01T21:17:47", "url": "https://files.pythonhosted.org/packages/b6/ce/ab602574fbbae73ce2f23a65398fd2316a8fca240e08c8d6ae11d7eedd08/retype-17.6.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8d25f86b10e488bc99dad9a4cada89c0", "sha256": "15d7369f5f22cf7507c7c9f2f396a613cf6a1a355abfe7132625055a48d16cc6" }, "downloads": -1, "filename": "retype-17.6.0.tar.gz", "has_sig": true, "md5_digest": "8d25f86b10e488bc99dad9a4cada89c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24685, "upload_time": "2017-06-01T21:17:48", "url": "https://files.pythonhosted.org/packages/ab/4e/a4b9f1163567c9cb295793c0ecd3b8cbe7c66eb7982a5935c1e32add2186/retype-17.6.0.tar.gz" } ], "17.6.1": [ { "comment_text": "", "digests": { "md5": "67eef834746d86dcd9f866f30258cf17", "sha256": "68f066eccc082d72be05bf49228d2ede0baa084e2e368627e532f92c501a3871" }, "downloads": -1, "filename": "retype-17.6.1-py3-none-any.whl", "has_sig": true, "md5_digest": "67eef834746d86dcd9f866f30258cf17", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 23636, "upload_time": "2017-06-07T18:57:12", "url": "https://files.pythonhosted.org/packages/a2/4f/205bccf8661d4dc3f44c96725b1b99544220a4d2e4da4b538273478827d0/retype-17.6.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1a7c79b1168f2d4fc48b3b040f5f534a", "sha256": "8538892f1e8fa6972d4e0833ad4cb0282f390a17ceb7ddfd4e31e14bc0faea44" }, "downloads": -1, "filename": "retype-17.6.1.tar.gz", "has_sig": true, "md5_digest": "1a7c79b1168f2d4fc48b3b040f5f534a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24975, "upload_time": "2017-06-07T18:57:14", "url": "https://files.pythonhosted.org/packages/dd/1b/ccd4b88b0c043668ed081a911a17918935fe9155968b13ba399d767c31a8/retype-17.6.1.tar.gz" } ], "17.6.2": [ { "comment_text": "", "digests": { "md5": "3bb3725e1106fd7ea70d4743d81223d4", "sha256": "bff17a11805aa0ddc77a66d5a29d24b694bf086d21aaf32f48691e10bb01e619" }, "downloads": -1, "filename": "retype-17.6.2-py3-none-any.whl", "has_sig": true, "md5_digest": "3bb3725e1106fd7ea70d4743d81223d4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 23688, "upload_time": "2017-06-07T21:36:34", "url": "https://files.pythonhosted.org/packages/71/5f/9f242d7cb5bfde882108fd5c41bf99625681dab5161fe60d30c276f7b7ed/retype-17.6.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3bdbd51404f38f2e7dd29d44f5b7e1e0", "sha256": "66f75235abec6a86ab2bcd4c62ddc5681b9c1b51384dd23c127e062e2a20c120" }, "downloads": -1, "filename": "retype-17.6.2.tar.gz", "has_sig": true, "md5_digest": "3bdbd51404f38f2e7dd29d44f5b7e1e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25115, "upload_time": "2017-06-07T21:36:37", "url": "https://files.pythonhosted.org/packages/d5/f9/f454c490e28c23a9055ba8c4026d64ef7f80a5802783844f34577a245382/retype-17.6.2.tar.gz" } ], "17.6.3": [ { "comment_text": "", "digests": { "md5": "37f6b2c94f3fdd797533996413954129", "sha256": "925928432394d4c9ff45c83011e42e4dab92bf287bb6ded2f46d244c2acb06f1" }, "downloads": -1, "filename": "retype-17.6.3-py3-none-any.whl", "has_sig": true, "md5_digest": "37f6b2c94f3fdd797533996413954129", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 24195, "upload_time": "2017-06-13T23:18:33", "url": "https://files.pythonhosted.org/packages/d3/33/7e26245f48775982c2a5965d2467201285047323c32f2da30539ec24065f/retype-17.6.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9b317169a719e39f64231f0b42cde6f2", "sha256": "17cef55eb11a9f5814056016c0e5971a02a600b17a85e67c4ce00b03c46487bb" }, "downloads": -1, "filename": "retype-17.6.3.tar.gz", "has_sig": true, "md5_digest": "9b317169a719e39f64231f0b42cde6f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25641, "upload_time": "2017-06-13T23:18:35", "url": "https://files.pythonhosted.org/packages/7b/9b/9630421367e88ccad46ae480980a39185578466f475d0c6d1df97c0be727/retype-17.6.3.tar.gz" } ], "19.9.0": [ { "comment_text": "", "digests": { "md5": "8764c3dbb9a2061d35c7b793ad0b413b", "sha256": "7d033b115f66e5327dea0a3fd7c9a3dbfa53841575daf27ce2ce409956d901d4" }, "downloads": -1, "filename": "retype-19.9.0-py3-none-any.whl", "has_sig": true, "md5_digest": "8764c3dbb9a2061d35c7b793ad0b413b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 36066, "upload_time": "2019-09-13T11:08:57", "url": "https://files.pythonhosted.org/packages/47/af/0a067a585721deb1637921aae7abaa15ee87601c2608ab66283005f1443c/retype-19.9.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7a052d83ae623b48782ac897bdb3fc08", "sha256": "846fd135d3ee33c1bad387602a405d808cb99a9a7a47299bfd0e1d25dfb2fedd" }, "downloads": -1, "filename": "retype-19.9.0.tar.gz", "has_sig": true, "md5_digest": "7a052d83ae623b48782ac897bdb3fc08", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 36630, "upload_time": "2019-09-13T11:08:59", "url": "https://files.pythonhosted.org/packages/2e/d1/37b8d4f29f1684a36a660b905401d3fedabdfa6af89a885d34bce31cf149/retype-19.9.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8764c3dbb9a2061d35c7b793ad0b413b", "sha256": "7d033b115f66e5327dea0a3fd7c9a3dbfa53841575daf27ce2ce409956d901d4" }, "downloads": -1, "filename": "retype-19.9.0-py3-none-any.whl", "has_sig": true, "md5_digest": "8764c3dbb9a2061d35c7b793ad0b413b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 36066, "upload_time": "2019-09-13T11:08:57", "url": "https://files.pythonhosted.org/packages/47/af/0a067a585721deb1637921aae7abaa15ee87601c2608ab66283005f1443c/retype-19.9.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7a052d83ae623b48782ac897bdb3fc08", "sha256": "846fd135d3ee33c1bad387602a405d808cb99a9a7a47299bfd0e1d25dfb2fedd" }, "downloads": -1, "filename": "retype-19.9.0.tar.gz", "has_sig": true, "md5_digest": "7a052d83ae623b48782ac897bdb3fc08", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 36630, "upload_time": "2019-09-13T11:08:59", "url": "https://files.pythonhosted.org/packages/2e/d1/37b8d4f29f1684a36a660b905401d3fedabdfa6af89a885d34bce31cf149/retype-19.9.0.tar.gz" } ] }