Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep unused import and pass statement #25

Closed
wants to merge 3 commits into from

Conversation

adhikasp
Copy link
Contributor

Make it possible to provide CLI args to keep autoflake from removing useless pass (--keep-useless-pass) and unused import (--keep-unused-import)

Closes #13 #10

@coveralls
Copy link

coveralls commented Aug 25, 2017

Coverage Status

Coverage increased (+0.03%) to 98.253% when pulling 14677f6 on adhikasp:modular into 459f5f5 on myint:master.

@myint
Copy link
Member

myint commented Aug 25, 2017

I'm not sure I want to add the --keep-useless-pass option. autoflake currently depends on temporarily replacing unused imports/variables with pass and then removing the useless ones in a second pass. This option would result in things like the following, where we end up leaving the code in a bit of a mess.

--- original/foo.py
+++ fixed/foo.py
@@ -1,3 +1,3 @@
 def foo():
-    x = 1
-    y = 2
+    pass
+    pass

I think to properly supporting this might involve significant restructuring of autoflake. Currently, I'm fine with supporting the 99% use case where we happen to remove useless pass statements. Though, if someone came up with an elegant solution to this, I'd be fine with that as well.

@adhikasp
Copy link
Contributor Author

Yes I agree this could make the resulting code clutters and the approach in this PR is too straightforward. I will close it in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants