Skip to content

Commit

Permalink
Merge pull request #23 from SublimeLinter/iterate
Browse files Browse the repository at this point in the history
Iterate
  • Loading branch information
kaste committed May 11, 2018
2 parents a2f5c70 + dd75e2f commit cf9c237
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions linter.py
@@ -1,12 +1,14 @@
from SublimeLinter.lint import PythonLinter, util, const
from SublimeLinter.lint import PythonLinter
from SublimeLinter.lint.linter import TransientError


class Pydocstyle(PythonLinter):
cmd = 'pydocstyle'
regex = r'^.+?:(?P<line>\d+).*:\r?\n\s*(?P<warning>D\d{3}):\s(?P<message>.+)$'
regex = r'''(?x)
^(?P<filename>.+):(?P<line>\d+)[^`\n]*(`(?P<near>.+)`)?.*:\n
\s*(?P<warning>D\d{3}):\s(?P<message>.+)
'''
multiline = True
default_type = const.WARNING
error_stream = util.STREAM_BOTH
line_col_base = (1, 0) # uses one-based line and zero-based column numbers
tempfile_suffix = 'py'
defaults = {
Expand All @@ -19,3 +21,20 @@ class Pydocstyle(PythonLinter):
'--convention=': '',
'--ignore-decorators=': ''
}

def on_stderr(self, stderr):
# For a doc style tester, parse errors can be treated 'transient',
# for the benefit, that we do not re-draw, but keep the errors from
# the last run.
if 'Cannot parse file' in stderr:
raise TransientError('Parse error.')

return super().on_stderr(stderr)

def split_match(self, match):
match = super().split_match(match)
if match.near and '__init__' not in match.message:
return match._replace(
message='{} `{}`'.format(match.message, match.near))

return match

0 comments on commit cf9c237

Please sign in to comment.