9
9
# License: MIT
10
10
#
11
11
12
- """This module exports the PEP8 plugin linter class."""
12
+ """This module exports the PYCODESTYLE plugin linter class."""
13
13
14
14
import os
15
15
16
16
from SublimeLinter .lint import persist , PythonLinter
17
17
18
18
19
- class PEP8 (PythonLinter ):
19
+ class PYCODESTYLE (PythonLinter ):
20
20
"""Provides an interface to the pep8 python module/script."""
21
21
22
22
syntax = 'python'
23
- cmd = ('pep8 @python' , '*' , '-' )
23
+ cmd = ('pycodestyle @python' , '*' , '-' )
24
24
version_args = '--version'
25
25
version_re = r'(?P<version>\d+\.\d+\.\d+)'
26
26
version_requirement = '>= 1.4.6'
@@ -33,14 +33,14 @@ class PEP8(PythonLinter):
33
33
}
34
34
inline_settings = 'max-line-length'
35
35
inline_overrides = ('select' , 'ignore' )
36
- module = 'pep8 '
36
+ module = 'pycodestyle '
37
37
check_version = True
38
38
39
39
# Internal
40
40
report = None
41
41
42
42
def check (self , code , filename ):
43
- """Run pep8 on code and return the output."""
43
+ """Run pycodestyle on code and return the output."""
44
44
options = {
45
45
'reporter' : self .get_report ()
46
46
}
@@ -56,25 +56,25 @@ def check(self, code, filename):
56
56
57
57
final_options = options .copy ()
58
58
59
- # Try to read options from pep8 default configuration files (.pep8 , tox.ini).
59
+ # Try to read options from pycodestyle default configuration files (.pycodestyle , tox.ini).
60
60
# If present, they will override the ones defined by Sublime Linter's config.
61
61
try :
62
- # `onError` will be called by `process_options` when no pep8 configuration file is found.
62
+ # `onError` will be called by `process_options` when no pycodestyle configuration file is found.
63
63
# Override needed to supress OptionParser.error() output in the default parser.
64
64
def onError (msg ):
65
65
pass
66
66
67
- from pep8 import process_options , get_parser
67
+ from pycodestyle import process_options , get_parser
68
68
parser = get_parser ()
69
69
parser .error = onError
70
- pep8_options , _ = process_options ([os .curdir ], True , True , parser = parser )
71
-
72
- # Merge options only if the pep8 config file actually exists;
73
- # pep8 always returns a config filename, even when it doesn't exist!
74
- if os .path .isfile (pep8_options .config ):
75
- pep8_options = vars (pep8_options )
76
- pep8_options .pop ('reporter' , None )
77
- for opt_n , opt_v in pep8_options .items ():
70
+ pycodestyle_options , _ = process_options ([os .curdir ], True , True , parser = parser )
71
+
72
+ # Merge options only if the pycodestyle config file actually exists;
73
+ # pycodestyle always returns a config filename, even when it doesn't exist!
74
+ if os .path .isfile (pycodestyle_options .config ):
75
+ pycodestyle_options = vars (pycodestyle_options )
76
+ pycodestyle_options .pop ('reporter' , None )
77
+ for opt_n , opt_v in pycodestyle_options .items ():
78
78
if isinstance (final_options .get (opt_n , None ), list ):
79
79
final_options [opt_n ] += opt_v
80
80
else :
@@ -97,7 +97,7 @@ def onError(msg):
97
97
def get_report (self ):
98
98
"""Return the Report class for use by flake8."""
99
99
if self .report is None :
100
- from pep8 import StandardReport
100
+ from pycodestyle import StandardReport
101
101
102
102
class Report (StandardReport ):
103
103
"""Provides a report in the form of a single multiline string, without printing."""
@@ -107,7 +107,7 @@ def get_file_results(self):
107
107
self ._deferred_print .sort ()
108
108
results = ''
109
109
110
- for line_number , offset , code , text , doc in self ._deferred_print :
110
+ for line_number , offset , code , text , _ in self ._deferred_print :
111
111
results += '{path}:{row}:{col}: {code} {text}\n ' .format_map ({
112
112
'path' : self .filename ,
113
113
'row' : self .line_offset + line_number ,
0 commit comments