99# License: MIT
1010#
1111
12- """This module exports the PEP8 plugin linter class."""
12+ """This module exports the PYCODESTYLE plugin linter class."""
1313
1414import os
1515
1616from SublimeLinter .lint import persist , PythonLinter
1717
1818
19- class PEP8 (PythonLinter ):
19+ class PYCODESTYLE (PythonLinter ):
2020 """Provides an interface to the pep8 python module/script."""
2121
2222 syntax = 'python'
23- cmd = ('pep8 @python' , '*' , '-' )
23+ cmd = ('pycodestyle @python' , '*' , '-' )
2424 version_args = '--version'
2525 version_re = r'(?P<version>\d+\.\d+\.\d+)'
2626 version_requirement = '>= 1.4.6'
@@ -33,14 +33,14 @@ class PEP8(PythonLinter):
3333 }
3434 inline_settings = 'max-line-length'
3535 inline_overrides = ('select' , 'ignore' )
36- module = 'pep8 '
36+ module = 'pycodestyle '
3737 check_version = True
3838
3939 # Internal
4040 report = None
4141
4242 def check (self , code , filename ):
43- """Run pep8 on code and return the output."""
43+ """Run pycodestyle on code and return the output."""
4444 options = {
4545 'reporter' : self .get_report ()
4646 }
@@ -56,25 +56,25 @@ def check(self, code, filename):
5656
5757 final_options = options .copy ()
5858
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).
6060 # If present, they will override the ones defined by Sublime Linter's config.
6161 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.
6363 # Override needed to supress OptionParser.error() output in the default parser.
6464 def onError (msg ):
6565 pass
6666
67- from pep8 import process_options , get_parser
67+ from pycodestyle import process_options , get_parser
6868 parser = get_parser ()
6969 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 ():
7878 if isinstance (final_options .get (opt_n , None ), list ):
7979 final_options [opt_n ] += opt_v
8080 else :
@@ -97,7 +97,7 @@ def onError(msg):
9797 def get_report (self ):
9898 """Return the Report class for use by flake8."""
9999 if self .report is None :
100- from pep8 import StandardReport
100+ from pycodestyle import StandardReport
101101
102102 class Report (StandardReport ):
103103 """Provides a report in the form of a single multiline string, without printing."""
@@ -107,7 +107,7 @@ def get_file_results(self):
107107 self ._deferred_print .sort ()
108108 results = ''
109109
110- for line_number , offset , code , text , doc in self ._deferred_print :
110+ for line_number , offset , code , text , _ in self ._deferred_print :
111111 results += '{path}:{row}:{col}: {code} {text}\n ' .format_map ({
112112 'path' : self .filename ,
113113 'row' : self .line_offset + line_number ,
0 commit comments