Skip to content

Commit

Permalink
Added --quiet option to suppress no issues (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
edvardm authored Aug 24, 2022
1 parent 4cd7114 commit bc62215
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion autoflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,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 @@ -1018,6 +1018,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 @@ -1404,6 +1404,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

0 comments on commit bc62215

Please sign in to comment.