mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-15 16:49:52 +00:00
Merge branch 'bug/279' into 'master'
Avoid calling rstrip on None Closes #279 See merge request !173
This commit is contained in:
commit
77d887f400
1 changed files with 15 additions and 10 deletions
|
|
@ -443,19 +443,24 @@ class FileChecker(object):
|
||||||
# numbers. We need to decrement the column number by 1 at
|
# numbers. We need to decrement the column number by 1 at
|
||||||
# least.
|
# least.
|
||||||
column_offset = 1
|
column_offset = 1
|
||||||
|
row_offset = 0
|
||||||
# See also: https://gitlab.com/pycqa/flake8/issues/237
|
# See also: https://gitlab.com/pycqa/flake8/issues/237
|
||||||
physical_line = token[-1]
|
physical_line = token[-1]
|
||||||
|
|
||||||
# NOTE(sigmavirus24): SyntaxErrors also don't exactly have a
|
# NOTE(sigmavirus24): Not all "tokens" have a string as the last
|
||||||
# "physical" line so much as what was accumulated by the point
|
# argument. In this event, let's skip trying to find the correct
|
||||||
# tokenizing failed.
|
# column and row values.
|
||||||
# See also: https://gitlab.com/pycqa/flake8/issues/237
|
if physical_line is not None:
|
||||||
lines = physical_line.rstrip('\n').split('\n')
|
# NOTE(sigmavirus24): SyntaxErrors also don't exactly have a
|
||||||
row_offset = len(lines) - 1
|
# "physical" line so much as what was accumulated by the point
|
||||||
logical_line = lines[0]
|
# tokenizing failed.
|
||||||
logical_line_length = len(logical_line)
|
# See also: https://gitlab.com/pycqa/flake8/issues/237
|
||||||
if column > logical_line_length:
|
lines = physical_line.rstrip('\n').split('\n')
|
||||||
column = logical_line_length
|
row_offset = len(lines) - 1
|
||||||
|
logical_line = lines[0]
|
||||||
|
logical_line_length = len(logical_line)
|
||||||
|
if column > logical_line_length:
|
||||||
|
column = logical_line_length
|
||||||
row -= row_offset
|
row -= row_offset
|
||||||
column -= column_offset
|
column -= column_offset
|
||||||
return row, column
|
return row, column
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue