{ "info": { "author": "Aaron Meurer", "author_email": "asmeurer@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# removestar\n\n[![Build Status](https://travis-ci.com/asmeurer/removestar.svg?branch=master)](https://travis-ci.com/asmeurer/removestar)\n\nTool to automatically replace `import *` imports with explicit imports\n\nRequires pyflakes.\n\nCurrent limitations:\n\n- Assumes only names in the current file are used by star imports (e.g., it\n won't work to replace star imports in `__init__.py`).\n\nFor files within the same module, removestar determines missing imported names\nstatically. For external library imports, including imports of standard\nlibrary modules, it dynamically imports the module to determine the names.\nThis can be disabled with the `--no-dynamic-importing` flag.\n\nSee the [issue tracker](https://github.com/asmeurer/removestar/issues). Pull\nrequests are welcome.\n\n## Installation\n\n```\npip install removestar\n```\n\nor if you use conda\n\n```\nconda install -c conda-forge removestar\n```\n\n## Usage\n\n```\n$ removestar file.py # Shows diff but does not edit file.py\n\n$ removestar -i file.py # Edits file.py in-place\n\n$ removestar -i module/ # Modifies every Python file in module/ recursively\n```\n\n## Why is `import *` so bad?\n\nDoing `from module import *` is generally frowned upon in Python. It is\nconsidered acceptable when working interactively at a `python` prompt, or in\n`__init__.py` files (removestar skips `__init__.py` files by default).\n\nSome reasons why `import *` is bad:\n\n- It hides which names are actually imported.\n- It is difficult both for human readers and static analyzers such as\n pyflakes to tell where a given name comes from when `import *` is used. For\n example, pyflakes cannot detect unused names (for instance, from typos) in\n the presence of `import *`.\n- If there are multiple `import *` statements, it may not be clear which names\n come from which module. In some cases, both modules may have a given name,\n but only the second import will end up being used. This can break people's\n intuition that the order of imports in a Python file generally does not\n matter.\n- `import *` often imports more names than you would expect. Unless the module\n you import defines `__all__` or carefully `del`s unused names at the module\n level, `import *` will import every public (doesn't start with an\n underscore) name defined in the module file. This can often include things\n like standard library imports or loop variables defined at the top-level of\n the file. For imports from modules (from `__init__.py`), `from module import\n *` will include every submodule defined in that module. Using `__all__` in\n modules and `__init__.py` files is also good practice, as these things are\n also often confusing even for interactive use where `import *` is\n acceptable.\n- In Python 3, `import *` is syntactically not allowed inside of a function.\n\nHere are some official Python references stating not to use `import *` in\nfiles:\n\n- [The official Python\n FAQ](https://docs.python.org/3/faq/programming.html?highlight=faq#what-are-the-best-practices-for-using-import-in-a-module):\n\n > In general, don\u2019t use `from modulename import *`. Doing so clutters the\n > importer\u2019s namespace, and makes it much harder for linters to detect\n > undefined names.\n\n- [PEP 8](https://www.python.org/dev/peps/pep-0008/#imports) (the official\n Python style guide):\n\n > Wildcard imports (`from import *`) should be avoided, as they\n > make it unclear which names are present in the namespace, confusing both\n > readers and many automated tools.\n\nUnfortunately, if you come across a file in the wild that uses `import *`, it\ncan be hard to fix it, because you need to find every name in the file that is\nimported from the `*`. Removestar makes this easy by finding which names come\nfrom `*` imports and replacing the import lines in the file automatically.\n\n## Example\n\nSuppose you have a module `mymod` like\n\n```\nmymod/\n | __init__.py\n | a.py\n | b.py\n```\n\nWith\n\n```py\n# mymod/a.py\nfrom .b import *\n\ndef func(x):\n return x + y\n```\n\n```py\n# mymod/b.py\nx = 1\ny = 2\n```\n\nThen `removestar` works like:\n\n```\n$ removestar mymod/\n\n--- original/mymod/a.py\n+++ fixed/mymod/a.py\n@@ -1,5 +1,5 @@\n # mymod/a.py\n-from .b import *\n+from .b import y\n\n def func(x):\n return x + y\n\n```\n\nThis does not edit `a.py` by default. The `-i` flag causes it to edit `a.py` in-place:\n\n```\n$ removestar -i mymod/\n$ cat mymod/a.py\n# mymod/a.py\nfrom .b import y\n\ndef func(x):\n return x + y\n```\n\n## Command line options\n\n\n\n```\n$ removestar --help\nusage: removestar [-h] [-i] [--version] [--no-skip-init]\n [--no-dynamic-importing] [-v] [-q]\n [--max-line-length MAX_LINE_LENGTH]\n paths [paths ...]\n\nTool to automatically replace \"import *\" imports with explicit imports\n\nRequires pyflakes.\n\nUsage:\n\n$ removestar file.py # Shows diff but does not edit file.py\n\n$ removestar -i file.py # Edits file.py in-place\n\n$ removestar -i module/ # Modifies every Python file in module/ recursively\n\npositional arguments:\n paths Files or directories to fix\n\noptional arguments:\n -h, --help show this help message and exit\n -i, --in-place Edit the files in-place. (default: False)\n --version Show removestar version number and exit.\n --no-skip-init Don't skip __init__.py files (they are skipped by\n default) (default: True)\n --no-dynamic-importing\n Don't dynamically import modules to determine the list\n of names. This is required for star imports from\n external modules and modules in the standard library.\n (default: True)\n -v, --verbose Print information about every imported name that is\n replaced. (default: False)\n -q, --quiet Don't print any warning messages. (default: False)\n --max-line-length MAX_LINE_LENGTH\n The maximum line length for replaced imports before\n they are wrapped. Set to 0 to disable line wrapping.\n (default: 100)\n```\n\n## Changelog\n\nSee the [CHANGELOG](CHANGELOG.md) file.\n\n## License\n\n[MIT](LICENSE)\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://www.asmeurer.com/removestar/", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "removestar", "package_url": "https://pypi.org/project/removestar/", "platform": "", "project_url": "https://pypi.org/project/removestar/", "project_urls": { "Homepage": "https://www.asmeurer.com/removestar/" }, "release_url": "https://pypi.org/project/removestar/1.2.2/", "requires_dist": [ "pyflakes" ], "requires_python": ">=3.6", "summary": "A tool to automatically replace 'import *' imports with explicit imports in files", "version": "1.2.2" }, "last_serial": 5717602, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "c7604a2e1e496e320d07f2b5ce6419cf", "sha256": "f85ef6163447c12f96d390bdc83aa42f24a6d5116ead26049ac8d96d76fa2003" }, "downloads": -1, "filename": "removestar-1.0.tar.gz", "has_sig": false, "md5_digest": "c7604a2e1e496e320d07f2b5ce6419cf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 19938, "upload_time": "2019-07-18T23:14:04", "url": "https://files.pythonhosted.org/packages/22/2e/e544f8001266ee32dd9f331612d1975ce0011248e8a66d89f91d7e583c51/removestar-1.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "eccbd61deda44b3da8b56a11e3d18075", "sha256": "bd06794cc8c715ca4b64df9ca8a41f0260535e7303f5b3602b94c370e2e9afe3" }, "downloads": -1, "filename": "removestar-1.0.1.tar.gz", "has_sig": false, "md5_digest": "eccbd61deda44b3da8b56a11e3d18075", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 20252, "upload_time": "2019-07-18T23:54:03", "url": "https://files.pythonhosted.org/packages/0b/4e/01cf6bb8d9ce2ad2921d33af3b893a5481e0b1ff1af3ddba4c055269206d/removestar-1.0.1.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "78a1aedfca63f41e37d2b4cde5061d98", "sha256": "5eb615c99dc38b61aad82d39ea9a0b0c103aa82acf608d06c00ca58ce4fae895" }, "downloads": -1, "filename": "removestar-1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "78a1aedfca63f41e37d2b4cde5061d98", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 13949, "upload_time": "2019-08-05T21:42:04", "url": "https://files.pythonhosted.org/packages/b6/75/aa9d088ec379c8513e7fe291053af0406a876d4d37a30c03071b100e8e4a/removestar-1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b507e2af865e7bb1029c15e3ca618840", "sha256": "ece95f52afa7fb293767b39bba2fc1f0ffa12a711dea7676128f2b6f31668af9" }, "downloads": -1, "filename": "removestar-1.1.tar.gz", "has_sig": false, "md5_digest": "b507e2af865e7bb1029c15e3ca618840", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 28336, "upload_time": "2019-08-05T21:42:06", "url": "https://files.pythonhosted.org/packages/87/81/8a57a5c67917323a8b787d2bc8f1dda86318415fb96f028cc6f0d8f52c0a/removestar-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "43a154cf13313f28b0629dbe9ea747bb", "sha256": "0a44daba13495e365f2662c8282bfaf6993e35251ebb5e881833809d367c6e96" }, "downloads": -1, "filename": "removestar-1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "43a154cf13313f28b0629dbe9ea747bb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 15979, "upload_time": "2019-08-17T06:50:33", "url": "https://files.pythonhosted.org/packages/39/73/82698b297052346d66c621ec05d91be81079e742ef034996c3070ac26dcc/removestar-1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b14aff7e2d23e39fbe78d549fb84d325", "sha256": "e78324a69ab3f812075f6f96ff91607de988025c0002c91351f1e7775ad3c299" }, "downloads": -1, "filename": "removestar-1.2.tar.gz", "has_sig": false, "md5_digest": "b14aff7e2d23e39fbe78d549fb84d325", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 30741, "upload_time": "2019-08-17T06:50:35", "url": "https://files.pythonhosted.org/packages/ce/17/bb8d7048fec61f4b70cf0ff91ce0c70cd0f314e7226c8b6c817f7e502d57/removestar-1.2.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "0675b784ff459723f3bbbc483029b3e1", "sha256": "bb04b56c8bf3c4c30cac4aef63b599335aea05cf8d25d4bddf94ce861d61e153" }, "downloads": -1, "filename": "removestar-1.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "0675b784ff459723f3bbbc483029b3e1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 16089, "upload_time": "2019-08-17T18:12:23", "url": "https://files.pythonhosted.org/packages/0d/ee/abb8dfa207cba774604c3143ff8c198e7aabecd99692df40bf32f9b803f9/removestar-1.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "af4a958f452c98135d68b386f24ca8c9", "sha256": "4ae7675f4f1cfba4cbde606caa16c6ac26d67aae5f438ffebf4e51539398fa0e" }, "downloads": -1, "filename": "removestar-1.2.1.tar.gz", "has_sig": false, "md5_digest": "af4a958f452c98135d68b386f24ca8c9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 30815, "upload_time": "2019-08-17T18:12:25", "url": "https://files.pythonhosted.org/packages/af/a9/846cf91ce18209bc2dde9f2aac1f599d087608e619d5dc7e059ef0346b36/removestar-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "d2ecbc479b5331f63c8ae460f8898fc6", "sha256": "1a8048147a31da8a89bbeab6cedc4b250f624147c54438a3e1a84d010001051c" }, "downloads": -1, "filename": "removestar-1.2.2-py3-none-any.whl", "has_sig": true, "md5_digest": "d2ecbc479b5331f63c8ae460f8898fc6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 17412, "upload_time": "2019-08-22T21:55:48", "url": "https://files.pythonhosted.org/packages/44/94/70ad839785699f2e2d55e9b6008fdcd8106b16c2042c65a6c4c09f3f5a23/removestar-1.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b79d76abcdb77a7d8fa15e39dda31b35", "sha256": "8f2413fd1e2d735c6d7df271b4e2e3906d1a49d8debb620814dca249d57c296c" }, "downloads": -1, "filename": "removestar-1.2.2.tar.gz", "has_sig": false, "md5_digest": "b79d76abcdb77a7d8fa15e39dda31b35", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 33208, "upload_time": "2019-08-22T21:55:50", "url": "https://files.pythonhosted.org/packages/0e/ed/1959b9f47355def06b2d31a3233be802cdb174c27f16e098fbf6bd1ab3ea/removestar-1.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d2ecbc479b5331f63c8ae460f8898fc6", "sha256": "1a8048147a31da8a89bbeab6cedc4b250f624147c54438a3e1a84d010001051c" }, "downloads": -1, "filename": "removestar-1.2.2-py3-none-any.whl", "has_sig": true, "md5_digest": "d2ecbc479b5331f63c8ae460f8898fc6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 17412, "upload_time": "2019-08-22T21:55:48", "url": "https://files.pythonhosted.org/packages/44/94/70ad839785699f2e2d55e9b6008fdcd8106b16c2042c65a6c4c09f3f5a23/removestar-1.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b79d76abcdb77a7d8fa15e39dda31b35", "sha256": "8f2413fd1e2d735c6d7df271b4e2e3906d1a49d8debb620814dca249d57c296c" }, "downloads": -1, "filename": "removestar-1.2.2.tar.gz", "has_sig": false, "md5_digest": "b79d76abcdb77a7d8fa15e39dda31b35", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 33208, "upload_time": "2019-08-22T21:55:50", "url": "https://files.pythonhosted.org/packages/0e/ed/1959b9f47355def06b2d31a3233be802cdb174c27f16e098fbf6bd1ab3ea/removestar-1.2.2.tar.gz" } ] }