autoflake
autoflake copied to clipboard
autoflake seems to exit 0 even if a diff is produced
% /path/to/python3 -m autoflake ~/autoflake_test --remove-all-unused-imports --remove-unused-variables -r --exclude whatever/*
--- original//Users/brandon/autoflake_test/test.py
+++ fixed//Users/brandon/autoflake_test/test.py
@@ -1,3 +1,3 @@
def main():
- thing = "blah"
+ pass
main()
--- original//Users/brandon/autoflake_test/test2.py
+++ fixed//Users/brandon/autoflake_test/test2.py
@@ -1,3 +1,3 @@
def main():
- thing = "blah"
+ pass
main()
% echo $?
0
This makes it harder to run in CI because it's not exiting zero. What's the intended behavior here?
-c, --check return error code if changes are needed
-m autoflake ~/autoflake_test --remove-all-unused-imports --remove-unused-variables -r --exclude whatever/*
If -c
is used, the diff is suppressed. So this would make CI fail but would make it harder to know why. :/
Would you consider a bug that -c
causes the diff to get suppressed?
+1. Ideally -c should print the diff to stdout. An alternative could be a flag which toggles diff view or the condensed view that -c defaults to now.
@fsouza is there a requirement to keep backwards compatibility? Otherwise I'd propose that --check spits out the diff as well. If we need backwards compatibility maybe another keyword should be introduced which makes --check print diffs?
I'm able to fix it either way but I'd appreciate your input first.
@ericstengard can we do that via a new flag? This way we can keep backwards compatibility.
@ericstengard can we do that via a new flag? This way we can keep backwards compatibility.
Yes I'd say that it's fine. I'm thinking something like --check-verbose or --check-diff since --check by default makes it less verbose. I'm leaning more towards --check-diff.