-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to expand single star import
This patch add new feature to automatically expand a star (wildcard) import to specify all names that used inside the code. A sample code like this ```python from math import * sin(1) cos(0) ``` will be changed into ```python from math import cos, sin sin(1) cos(0) ``` Note that there are still 2 bugs regarding this feature, which mainly caused by related upstream bug from pyflakes: 1. A function/names that declared but later deleted by `del` command will raise a false positive that the names is undeclared and could possibly come from a star import (if present). PyCQA/pyflakes#175 2. pyflakes is "inconsistent" on defining an undefined var in case of __all__ is used (like in module API files). ```python from foo import * # contain function_1 and function_2 __all__ = ['function_1', 'function_2', 'function_3'] function_2() # just use it somewhere to trigger pyflake def function_3: return 'something' ``` pyflakes will complain that function_2 is undefined and possibly come from module foo. The import then will be expanded into... ```python from foo import function_2 ``` But then pyflakes will complain function_1 is undefined because its used in `__all__` Closes #14
- Loading branch information
Showing
3 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters