diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-07-25 10:40:22 -0500 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-07-25 11:00:18 -0500 |
| commit | 299e200cb981f4c0823a1fe9cd3baecc00a79203 (patch) | |
| tree | 20374b4dfd9bde501d7d231f386ae3caff4b0dce /src | |
| parent | 217aa8185c784f6514ef2004c110e1f33d4dc6c3 (diff) | |
| download | flake8-299e200cb981f4c0823a1fe9cd3baecc00a79203.tar.gz | |
Handle multiline strings with '# noqa'
In Flake8 2.x we allowed people to use # noqa at the end of a multiline
string to ignore errors inside the string (e.g., E501). Being blissfully
ignorant of this, I never accounted for it in Flake8 3. This fixes the
oversight and allows multiline statements to have the # noqa at the end.
Closes #177
Diffstat (limited to 'src')
| -rw-r--r-- | src/flake8/__init__.py | 2 | ||||
| -rw-r--r-- | src/flake8/checker.py | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/flake8/__init__.py b/src/flake8/__init__.py index 8ebfde1..7a90d28 100644 --- a/src/flake8/__init__.py +++ b/src/flake8/__init__.py @@ -27,7 +27,7 @@ LOG.addHandler(NullHandler()) # Clean up after LOG config del NullHandler -__version__ = '3.0.0' +__version__ = '3.0.1' __version_info__ = tuple(int(i) for i in __version__.split('.') if i.isdigit()) diff --git a/src/flake8/checker.py b/src/flake8/checker.py index 99bacb5..09168ee 100644 --- a/src/flake8/checker.py +++ b/src/flake8/checker.py @@ -425,16 +425,16 @@ class FileChecker(object): self.report('E902', 0, 0, message) return None - def report(self, error_code, line_number, column, text): + def report(self, error_code, line_number, column, text, line=None): # type: (str, int, int, str) -> str """Report an error by storing it in the results list.""" if error_code is None: error_code, text = text.split(' ', 1) - physical_line = '' + physical_line = line # If we're recovering from a problem in _make_processor, we will not # have this attribute. - if getattr(self, 'processor', None): + if not physical_line and getattr(self, 'processor', None): physical_line = self.processor.line_for(line_number) error = (error_code, line_number, column, text, physical_line) @@ -504,7 +504,7 @@ class FileChecker(object): self.processor.next_logical_line() - def run_physical_checks(self, physical_line): + def run_physical_checks(self, physical_line, override_error_line=None): """Run all checks for a given physical line.""" for plugin in self.checks.physical_line_plugins: self.processor.update_checker_state_for(plugin) @@ -516,6 +516,7 @@ class FileChecker(object): line_number=self.processor.line_number, column=column_offset, text=text, + line=(override_error_line or physical_line), ) self.processor.check_physical_error(error_code, physical_line) @@ -611,7 +612,8 @@ class FileChecker(object): line_no = token[2][0] with self.processor.inside_multiline(line_number=line_no): for line in self.processor.split_line(token): - self.run_physical_checks(line + '\n') + self.run_physical_checks(line + '\n', + override_error_line=token[4]) def find_offset(offset, mapping): |
