Disable 'BINARY file' warning by default (#1441) * 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 <waldyrious@gmail.com> * Improve help message for the --quiet-level option * Update _codespell.py Co-authored-by: Anatol Pomozov <anatol.pomozov@gmail.com> Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index 17fc3b9..68a0bb4 100755 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py
@@ -282,15 +282,20 @@ '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,
diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py index b766451..4a54fd0 100644 --- a/codespell_lib/tests/test_basic.py +++ b/codespell_lib/tests/test_basic.py
@@ -242,8 +242,9 @@ 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)