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

Added --quiet option to suppress no issues #89

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion autoflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def fix_file(filename, args, standard_out):
filename)
standard_out.write(''.join(diff))
else:
if args.check:
if args.check and not args.quiet:
standard_out.write('No issues detected!\n')
else:
_LOGGER.debug('Clean %s: nothing to fix', filename)
Expand Down Expand Up @@ -1024,6 +1024,8 @@ def _main(argv, standard_out, standard_error):
help='remove unused variables')
parser.add_argument('--version', action='version',
version='%(prog)s ' + __version__)
parser.add_argument('--quiet', action='store_true',
help='Suppress output if there are no issues')
parser.add_argument('-v', '--verbose', action='count', dest='verbosity',
default=0, help='print more verbose logs (you can '
'repeat `-v` to make it more verbose)')
Expand Down
13 changes: 13 additions & 0 deletions test_autoflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,19 @@ def test_check_correct_file(self):
standard_error=None)
self.assertEqual('No issues detected!\n', output_file.getvalue())

def test_check_correct_file_with_quiet(self):
with temporary_file("""\
import foo
x = foo.bar
print(x)
""") as filename:
output_file = io.StringIO()
autoflake._main(argv=['my_fake_program', '--check', '--quiet',
filename],
standard_out=output_file,
standard_error=None)
self.assertEqual('', output_file.getvalue())

def test_check_useless_pass(self):
with temporary_file("""\
import foo
Expand Down