-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
Description
Thesis
pycln should perform scope analythis and remove unused imports accordingly.
Reasoning
This would be consistent with flake8, pylance and PyCharms behaviour in identifying unused imports.
autoflake and unimport are able to remove them as well
cat test.py
import sys
def func():
import sys
def inner():
import sys
sys.exit(0)
pycln
$ pycln test.py
Looks good! ✨ 🍰 ✨
1 file left unchanged.
autoflake
$ autoflake test.py
--- original/test.py
+++ fixed/test.py
@@ -1,8 +1,7 @@
-import sys
def func():
- import sys
+ pass
def inner():
import sys
unimport
$ unimport -d test.py
--- test.py
+++
@@ -1,8 +1,6 @@
-import sys
def func():
- import sys
def inner():
import sys