Skip to content

Commit

Permalink
Disable 'BINARY file' warning by default (#1441)
Browse files Browse the repository at this point in the history
* Disable 'BINARY file' warning by default

Currently codespell prints a warning if it finds binary files in the tree.
This is annoying as many projects contain .git/.svn blobs, images, etc.
Disable the warning by default and let users enable it if needed.

Co-authored-by: Waldir Pimenta <[email protected]>

* Improve help message for the --quiet-level option

* Update _codespell.py

Co-authored-by: Anatol Pomozov <[email protected]>
Co-authored-by: Eric Larson <[email protected]>
  • Loading branch information
3 people authored Jun 11, 2020
1 parent 5ed84fc commit a24deba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 13 additions & 8 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,20 @@ def parse_options(args):
'is available. 3: both 1 and 2')

parser.add_argument('-q', '--quiet-level',
action='store', type=int, default=0,
help='Bitmask that allows codespell to run quietly. '
'0: the default, in which all messages are '
'printed. 1: disable warnings about wrong '
'encoding. 2: disable warnings about binary '
'file. 4: shut down warnings about automatic '
'fixes that were disabled in dictionary. '
action='store', type=int, default=2,
help='Bitmask that allows suppressing messages. '
'0: print all messages. '
'1: disable warnings about wrong encoding. '
'2: disable warnings about binary files. '
'4: omit warnings about automatic fixes that '
'were disabled in the dictionary. '
'8: don\'t print anything for non-automatic '
'fixes. 16: don\'t print fixed files.')
'fixes. '
'16: don\'t print the list of fixed files. '
'As usual with bitmasks, these levels can be '
'combined; e.g. use 3 for levels 1+2, 7 for '
'1+2+4, 23 for 1+2+4+16, etc. '
'The default mask is %(default)s.')

parser.add_argument('-e', '--hard-encoding-detection',
action='store_true', default=False,
Expand Down
3 changes: 2 additions & 1 deletion codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ def test_encoding(tmpdir, capsys):
f.write(b'\x00\x00naiive\x00\x00')
capsys.readouterr()
assert cs.main(f.name) == 0
assert capsys.readouterr() == ('', '')
assert cs.main('-q', '0', f.name) == 0
assert 'WARNING: Binary file' in capsys.readouterr()[1]
assert cs.main('-q', '2', f.name) == 0
assert capsys.readouterr() == ('', '')
finally:
os.remove(f.name)
Expand Down

0 comments on commit a24deba

Please sign in to comment.