mirror of https://github.com/zulip/zulip.git
zulint: Move pycodestyle runner code to library.
This way, only the Zulip project's specific configuration ends up living in pep8.py.
This commit is contained in:
parent
3b53ddf779
commit
458c17868f
|
@ -3,27 +3,12 @@ from __future__ import absolute_import
|
|||
|
||||
import subprocess
|
||||
|
||||
from zulint.printer import print_err, colors
|
||||
from zulint.linters import run_pycodestyle
|
||||
|
||||
from typing import List
|
||||
|
||||
def check_pep8(files):
|
||||
# type: (List[str]) -> bool
|
||||
|
||||
def run_pycodestyle(files, ignored_rules):
|
||||
# type: (List[str], List[str]) -> bool
|
||||
failed = False
|
||||
color = next(colors)
|
||||
pep8 = subprocess.Popen(
|
||||
['pycodestyle'] + files + ['--ignore={rules}'.format(rules=','.join(ignored_rules))],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
assert pep8.stdout is not None # Implied by use of subprocess.PIPE
|
||||
for line in iter(pep8.stdout.readline, b''):
|
||||
print_err('pep8', color, line)
|
||||
failed = True
|
||||
return failed
|
||||
|
||||
failed = False
|
||||
ignored_rules = [
|
||||
# Each of these rules are ignored for the explained reason.
|
||||
|
||||
|
@ -96,9 +81,4 @@ def check_pep8(files):
|
|||
# 'W504',
|
||||
]
|
||||
|
||||
if len(files) == 0:
|
||||
return False
|
||||
|
||||
failed = run_pycodestyle(files, ignored_rules)
|
||||
|
||||
return failed
|
||||
return run_pycodestyle(files, ignored_rules)
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
|
||||
import subprocess
|
||||
from typing import List
|
||||
|
||||
from zulint.printer import print_err, colors
|
||||
|
||||
def run_pycodestyle(files, ignored_rules):
|
||||
# type: (List[str], List[str]) -> bool
|
||||
if len(files) == 0:
|
||||
return False
|
||||
|
||||
failed = False
|
||||
color = next(colors)
|
||||
pep8 = subprocess.Popen(
|
||||
['pycodestyle'] + files + ['--ignore={rules}'.format(rules=','.join(ignored_rules))],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
assert pep8.stdout is not None # Implied by use of subprocess.PIPE
|
||||
for line in iter(pep8.stdout.readline, b''):
|
||||
print_err('pep8', color, line)
|
||||
failed = True
|
||||
return failed
|
Loading…
Reference in New Issue