summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-12-03 17:45:45 +0000
committerAnthony Sottile <asottile@umich.edu>2019-12-03 17:45:45 +0000
commit21d2adf21f86471d0bf56e6d444764aa3bb35884 (patch)
tree18395a71ffe24a7f03dae269e611632d914b81ca
parent2ab681a4be8bc9a422080ad7f8c3a871292b90fa (diff)
parent3b80b2e05a075e8de7149035643b2498e5a25c02 (diff)
downloadflake8-21d2adf21f86471d0bf56e6d444764aa3bb35884.tar.gz
Merge branch 'fix/disable_noqa' into 'master'
`--disable-noqa` does not override `# flake8: noqa` Closes #590 See merge request pycqa/flake8!380
-rw-r--r--src/flake8/processor.py5
-rw-r--r--tests/unit/conftest.py1
-rw-r--r--tests/unit/test_file_processor.py10
3 files changed, 15 insertions, 1 deletions
diff --git a/src/flake8/processor.py b/src/flake8/processor.py
index ea8d3e2..0fd650b 100644
--- a/src/flake8/processor.py
+++ b/src/flake8/processor.py
@@ -346,7 +346,10 @@ class FileProcessor(object):
:rtype:
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
elif any(defaults.NOQA_FILE.search(line) for line in self.lines):
LOG.warning(
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py
index 3541ec3..eb76f98 100644
--- a/tests/unit/conftest.py
+++ b/tests/unit/conftest.py
@@ -11,6 +11,7 @@ def options_from(**kwargs):
kwargs.setdefault('max_doc_length', None)
kwargs.setdefault('verbose', False)
kwargs.setdefault('stdin_display_name', 'stdin')
+ kwargs.setdefault('disable_noqa', False)
return argparse.Namespace(**kwargs)
diff --git a/tests/unit/test_file_processor.py b/tests/unit/test_file_processor.py
index afae77d..f38568c 100644
--- a/tests/unit/test_file_processor.py
+++ b/tests/unit/test_file_processor.py
@@ -76,6 +76,16 @@ def test_should_ignore_file(lines, expected, default_options):
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')
def test_read_lines_from_stdin(stdin_get_value, default_options):
"""Verify that we use our own utility function to retrieve stdin."""