mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-29 10:36:53 +00:00
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
This commit is contained in:
parent
217aa8185c
commit
299e200cb9
4 changed files with 19 additions and 6 deletions
10
docs/source/release-notes/3.0.1.rst
Normal file
10
docs/source/release-notes/3.0.1.rst
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
3.0.1 -- 2016-07-25
|
||||
-------------------
|
||||
|
||||
- Fix regression in handling of ``# noqa`` for multiline strings.
|
||||
(See also `GitLab#177`_)
|
||||
|
||||
|
||||
.. links
|
||||
.. _GitLab#177:
|
||||
https://gitlab.com/pycqa/flake8/issues/177
|
||||
|
|
@ -6,6 +6,7 @@ All of the release notes that have been recorded for Flake8 are organized here
|
|||
with the newest releases first.
|
||||
|
||||
.. toctree::
|
||||
3.0.1
|
||||
3.0.0
|
||||
2.6.2
|
||||
2.6.1
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue