Skip to content

Commit 88e7880

Browse files
authored
Merge pull request #21 from SublimeLinter/sl4-cleanup
clean up for SL4
2 parents b3666f6 + 3d3ad5c commit 88e7880

File tree

1 file changed

+4
-81
lines changed

1 file changed

+4
-81
lines changed

linter.py

Lines changed: 4 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,16 @@
1-
#
2-
# linter.py
3-
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
4-
#
5-
# Written by Aparajita Fishman
6-
# Copyright (c) 2015-2016 The SublimeLinter Community
7-
# Copyright (c) 2013-2014 Aparajita Fishman
8-
#
9-
# License: MIT
10-
#
11-
12-
"""This module exports the Pydocstyle plugin linter class."""
13-
14-
from contextlib import contextmanager
15-
from functools import partial
16-
import SublimeLinter.lint
17-
from SublimeLinter.lint import PythonLinter, persist, util
18-
19-
if getattr(SublimeLinter.lint, 'VERSION', 3) > 3:
20-
from SublimeLinter.lint import const
21-
WARNING = const.WARNING
22-
cmd = 'pydocstyle'
23-
module = None
24-
else:
25-
from SublimeLinter.lint import highlight
26-
WARNING = highlight.WARNING
27-
cmd = 'pydocstyle@python'
28-
module = 'pydocstyle'
1+
from SublimeLinter.lint import PythonLinter, util, const
292

303

314
class Pydocstyle(PythonLinter):
32-
"""Provides an interface to the pydocstyle python module/script."""
33-
34-
syntax = 'python'
35-
cmd = cmd
36-
version_args = '--version'
37-
version_re = r'(?P<version>\d+\.\d+\.\d+)'
38-
version_requirement = '>= 0.3.0'
5+
cmd = 'pydocstyle'
396
regex = r'^.+?:(?P<line>\d+).*:\r?\n\s*(?P<warning>D\d{3}):\s(?P<message>.+)$'
407
multiline = True
41-
default_type = WARNING
8+
default_type = const.WARNING
429
error_stream = util.STREAM_BOTH
4310
line_col_base = (1, 0) # uses one-based line and zero-based column numbers
4411
tempfile_suffix = 'py'
45-
module = module
4612
defaults = {
13+
'selector': 'source.python',
4714
'--add-ignore=': '',
4815
'--add-select=': '',
4916
'--ignore=': '',
@@ -52,47 +19,3 @@ class Pydocstyle(PythonLinter):
5219
'--convention=': '',
5320
'--ignore-decorators=': ''
5421
}
55-
inline_overrides = [
56-
'add-ignore',
57-
'add-select',
58-
'ignore',
59-
'select',
60-
'config',
61-
'convention',
62-
'ignore-decorators'
63-
]
64-
65-
if getattr(SublimeLinter.lint, 'VERSION', 3) < 4:
66-
def check(self, code, filename):
67-
"""Run pydocstyle on code and return the output."""
68-
args = self.build_args(self.get_view_settings(inline=True))
69-
70-
if persist.settings.get('debug'):
71-
persist.printf('{} args: {}'.format(self.name, args))
72-
73-
conf = self.module.config.ConfigurationParser()
74-
with partialpatched(conf,
75-
'_parse_args',
76-
args=args + [filename],
77-
values=None):
78-
conf.parse()
79-
80-
errors = []
81-
for fname, checked_codes, ignore_decorators in \
82-
conf.get_files_to_check():
83-
errors.extend(
84-
self.module.check(
85-
[fname],
86-
select=checked_codes,
87-
ignore_decorators=ignore_decorators))
88-
89-
return errors
90-
91-
92-
@contextmanager
93-
def partialpatched(obj, name, **kwargs):
94-
"""Monkey patch instance method with partial application."""
95-
pre_patched_value = getattr(obj, name)
96-
setattr(obj, name, partial(pre_patched_value, **kwargs))
97-
yield
98-
setattr(obj, name, pre_patched_value)

0 commit comments

Comments
 (0)