Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Use pycodestyle instead of pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Jun 7, 2017
1 parent 95380dc commit 4bfcaa5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
logger = logging.getLogger(__name__)


class PEP8Linter(PythonLinter):
name = 'pep8'
class PyCodeStyleLinter(PythonLinter):
name = 'pycodestyle'

def is_usable(self):
return in_path('pep8')
return in_path('pycodestyle')

def lint_files(self, files):
command = [self.python_name, '-m', 'pep8']
command = [self.python_name, '-m', 'pycodestyle']
command += files
_, output = run_command(command, split=True, cwd=self.working_dir)
if not output:
Expand All @@ -28,7 +28,7 @@ def lint_files(self, files):
yield Problem(filename, line, message, self.name)

def _parse_line(self, line):
"""pep8 only generates results as stdout.
"""pycodestyle only generates results as stdout.
Parse the output for real data."""
parts = line.split(':', 3)
message = parts[3].strip()
Expand Down
5 changes: 3 additions & 2 deletions badwolf/lint/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from badwolf.lint import Problems
from badwolf.lint.linters.eslint import ESLinter
from badwolf.lint.linters.flake8 import Flake8Linter
from badwolf.lint.linters.pep8 import PEP8Linter
from badwolf.lint.linters.pycodestyle import PyCodeStyleLinter
from badwolf.lint.linters.csslint import CSSLinter
from badwolf.lint.linters.shellcheck import ShellCheckLinter
from badwolf.lint.linters.jsonlint import JSONLinter
Expand All @@ -29,7 +29,8 @@ class LintProcessor(object):
LINTERS = {
'eslint': ESLinter,
'flake8': Flake8Linter,
'pep8': PEP8Linter,
'pep8': PyCodeStyleLinter,
'pycodestyle': PyCodeStyleLinter,
'csslint': CSSLinter,
'shellcheck': ShellCheckLinter,
'jsonlint': JSONLinter,
Expand Down
4 changes: 2 additions & 2 deletions docs/lint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
名称 编程语言 官网/文档地址
=================== =================== =======================================================
flake8 Python http://flake8.readthedocs.org/en/latest/
pep8 Python http://pep8.readthedocs.org/en/latest/
pylint Python http://pep8.readthedocs.org/en/latest/
pycodestyle Python http://pycodestyle.readthedocs.org/en/latest/
pylint Python http://pylint.readthedocs.org/en/latest/
bandit Python https://github.com/openstack/bandit
eslint JavaScript http://eslint.org/
csslint CSS http://csslint.net/
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ unidiff>=0.5.2
optionaldict>=0.1.1
flake8>=2.5.2
pep8-naming>=0.3.3
pep8>=1.7.0
pycodestyle
yamllint>=1.0.0
bandit>=0.17.3
restructuredtext-lint>=0.14.2
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def test_eslint_lint_a_js(app, caplog):
assert problem.line == 1


def test_pep8_lint_a_py(app, caplog):
def test_pycodestyle_lint_a_py(app, caplog):
diff = """diff --git a/a.py b/a.py
new file mode 100644
index 0000000..fdeea15
Expand All @@ -208,8 +208,8 @@ def test_pep8_lint_a_py(app, caplog):
pr_id=1
)
spec = Specification()
spec.linters.append(ObjectDict(name='pep8', pattern=None))
lint = LintProcessor(context, spec, os.path.join(FIXTURES_PATH, 'pep8'))
spec.linters.append(ObjectDict(name='pycodestyle', pattern=None))
lint = LintProcessor(context, spec, os.path.join(FIXTURES_PATH, 'pycodestyle'))
patch = PatchSet(diff.split('\n'))
with mock.patch.object(lint, 'load_changes') as load_changes,\
mock.patch.object(lint, 'update_build_status') as build_status,\
Expand Down

0 comments on commit 4bfcaa5

Please sign in to comment.