mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 21:16:54 +00:00
Merge branch 'fix/disable_noqa' into 'master'
`--disable-noqa` does not override `# flake8: noqa` Closes #590 See merge request pycqa/flake8!380
This commit is contained in:
commit
21d2adf21f
3 changed files with 15 additions and 1 deletions
|
|
@ -346,7 +346,10 @@ class FileProcessor(object):
|
||||||
:rtype:
|
:rtype:
|
||||||
bool
|
bool
|
||||||
"""
|
"""
|
||||||
if any(defaults.NOQA_FILE.match(line) for line in self.lines):
|
if (
|
||||||
|
not self.options.disable_noqa
|
||||||
|
and any(defaults.NOQA_FILE.match(line) for line in self.lines)
|
||||||
|
):
|
||||||
return True
|
return True
|
||||||
elif any(defaults.NOQA_FILE.search(line) for line in self.lines):
|
elif any(defaults.NOQA_FILE.search(line) for line in self.lines):
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ def options_from(**kwargs):
|
||||||
kwargs.setdefault('max_doc_length', None)
|
kwargs.setdefault('max_doc_length', None)
|
||||||
kwargs.setdefault('verbose', False)
|
kwargs.setdefault('verbose', False)
|
||||||
kwargs.setdefault('stdin_display_name', 'stdin')
|
kwargs.setdefault('stdin_display_name', 'stdin')
|
||||||
|
kwargs.setdefault('disable_noqa', False)
|
||||||
return argparse.Namespace(**kwargs)
|
return argparse.Namespace(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,16 @@ def test_should_ignore_file(lines, expected, default_options):
|
||||||
assert file_processor.should_ignore_file() is expected
|
assert file_processor.should_ignore_file() is expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_ignore_file_to_handle_disable_noqa(default_options):
|
||||||
|
"""Verify that we ignore a file if told to."""
|
||||||
|
lines = ['# flake8: noqa']
|
||||||
|
file_processor = processor.FileProcessor('-', default_options, lines)
|
||||||
|
assert file_processor.should_ignore_file() is True
|
||||||
|
default_options.disable_noqa = True
|
||||||
|
file_processor = processor.FileProcessor('-', default_options, lines)
|
||||||
|
assert file_processor.should_ignore_file() is False
|
||||||
|
|
||||||
|
|
||||||
@mock.patch('flake8.utils.stdin_get_value')
|
@mock.patch('flake8.utils.stdin_get_value')
|
||||||
def test_read_lines_from_stdin(stdin_get_value, default_options):
|
def test_read_lines_from_stdin(stdin_get_value, default_options):
|
||||||
"""Verify that we use our own utility function to retrieve stdin."""
|
"""Verify that we use our own utility function to retrieve stdin."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue