From 5144196abd99860a956c1b1ce7a4575b8e1d028b Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 10 Jul 2019 08:11:41 -0700 Subject: [PATCH] Do not pass `noqa` to plugins, have flake8 decide whether to report --- src/flake8/processor.py | 8 +++----- tests/integration/test_main.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/flake8/processor.py b/src/flake8/processor.py index 239f908..ffd8b91 100644 --- a/src/flake8/processor.py +++ b/src/flake8/processor.py @@ -47,6 +47,9 @@ class FileProcessor(object): - :attr:`verbose` """ + #: always ``False``, included for compatibility + noqa = False + def __init__(self, filename, options, lines=None): """Initialice our file processor. @@ -85,8 +88,6 @@ class FileProcessor(object): self.max_doc_length = options.max_doc_length #: Whether the current physical line is multiline self.multiline = False - #: Whether or not we're observing NoQA - self.noqa = False #: Previous level of indentation self.previous_indent_level = 0 #: Previous logical line @@ -171,7 +172,6 @@ class FileProcessor(object): self.previous_unindented_logical_line = self.logical_line self.blank_lines = 0 self.tokens = [] - self.noqa = False def build_logical_line_tokens(self): """Build the mapping, comments, and logical line lists.""" @@ -216,8 +216,6 @@ class FileProcessor(object): comments, logical, mapping_list = self.build_logical_line_tokens() joined_comments = "".join(comments) self.logical_line = "".join(logical) - if defaults.NOQA_INLINE_REGEXP.search(joined_comments): - self.noqa = True self.statistics["logical lines"] += 1 return joined_comments, self.logical_line, mapping_list diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py index 72e9621..8b78c04 100644 --- a/tests/integration/test_main.py +++ b/tests/integration/test_main.py @@ -128,6 +128,18 @@ def test_bug_report_successful(capsys): assert err == '' +def test_specific_noqa_does_not_clobber_pycodestyle_noqa(tmpdir, capsys): + """See https://gitlab.com/pycqa/flake8/issues/552.""" + with tmpdir.as_cwd(): + tmpdir.join('t.py').write("test = ('ABC' == None) # noqa: E501\n") + _call_main(['t.py'], retv=1) + + out, err = capsys.readouterr() + assert out == '''\ +t.py:1:15: E711 comparison to None should be 'if cond is None:' +''' + + def test_obtaining_args_from_sys_argv_when_not_explicity_provided(capsys): """Test that arguments are obtained from 'sys.argv'.""" with mock.patch('sys.argv', ['flake8', '--help']):