Skip to content

Commit

Permalink
Merge pull request #94 from SublimeLinter/iterate
Browse files Browse the repository at this point in the history
Extract useful parts from #93
  • Loading branch information
kaste authored May 14, 2018
2 parents a03d617 + dd22ad6 commit a197e33
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions linter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from SublimeLinter.lint import PythonLinter
import re

CAPTURE_WS = re.compile('(\s+)')
CAPTURE_WS = re.compile(r'(\s+)')


class Flake8(PythonLinter):
Expand Down Expand Up @@ -46,12 +46,12 @@ def split_match(self, match):
and a column will always override near.
"""
match, line, col, error, warning, message, near = super().split_match(match)
match = super().split_match(match)

if near:
col = None
if match.near:
return match._replace(col=None)

return match, line, col, error, warning, message, near
return match

def reposition_match(self, line, col, m, virtual_view):
"""Reposition white-space errors."""
Expand All @@ -75,9 +75,15 @@ def reposition_match(self, line, col, m, virtual_view):
return line - 1, 0, 1

if code == 'E303':
match = re.match('too many blank lines \((\d+)', m.message.strip())
match = re.match(r'too many blank lines \((\d+)', m.message.strip())
if match is not None:
count = int(match.group(1))
return (line - (count - 1), 0, count - 1)

if code == 'E999':
txt = virtual_view.select_line(line).rstrip('\n')
last_col = len(txt)
if col + 1 == last_col:
return line, last_col, last_col

return super().reposition_match(line, col, m, virtual_view)

0 comments on commit a197e33

Please sign in to comment.