diff options
| author | Ian Stapleton Cordasco <graffatcolmingov@gmail.com> | 2018-07-01 19:22:30 +0000 |
|---|---|---|
| committer | Ian Stapleton Cordasco <graffatcolmingov@gmail.com> | 2018-07-01 19:22:30 +0000 |
| commit | 9631dac52aa6ed8a3de9d0983c3c7b0267ae7d6d (patch) | |
| tree | c04047bce914dcc3c964487b65d6b2d363094caf /src/flake8 | |
| parent | eb6228b660a5194f201dcf8767f804f697756b79 (diff) | |
| parent | e73055432c5a28dc23e7440f5abb992335efe5c7 (diff) | |
| download | flake8-9631dac52aa6ed8a3de9d0983c3c7b0267ae7d6d.tar.gz | |
Merge branch 'flake8_noqa_line_by_self' into 'master'
Only skip a file if `# flake8: noqa` is on a line by itself
See merge request pycqa/flake8!219
Diffstat (limited to 'src/flake8')
| -rw-r--r-- | src/flake8/processor.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/flake8/processor.py b/src/flake8/processor.py index 3827a26..d54a82f 100644 --- a/src/flake8/processor.py +++ b/src/flake8/processor.py @@ -106,7 +106,7 @@ class FileProcessor(object): @property def file_tokens(self): - """The complete set of tokens for a file. + """Return the complete set of tokens for a file. Accessing this attribute *may* raise an InvalidSyntax exception. @@ -334,7 +334,7 @@ class FileProcessor(object): def should_ignore_file(self): # type: () -> bool - """Check if ``# flake8: noqa`` is in the file to be ignored. + """Check if ``flake8: noqa`` is in the file to be ignored. :returns: True if a line matches :attr:`defaults.NOQA_FILE`, @@ -342,8 +342,16 @@ class FileProcessor(object): :rtype: bool """ - ignore_file = defaults.NOQA_FILE.search - return any(ignore_file(line) for line in self.lines) + if 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( + 'Detected `flake8: noqa` on line with code. To ignore an ' + 'error on a line use `noqa` instead.', + ) + return False + else: + return False def strip_utf_bom(self): # type: () -> NoneType |
