Skip to content

Commit

Permalink
Remove pyflakes and pycodestyle integration.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Oct 26, 2023
1 parent 87e9a65 commit 9159a9f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ applications using a mix of third-party linters and custom rules.
Modern full-stack web applications generally involve code written in
several programming languages, each of which have their own standard
linter tools. For example, [Zulip](https://zulip.com) uses Python
(mypy/pyflake/pycodestyle), JavaScript (eslint), CSS (stylelint),
(mypy, Ruff), JavaScript (eslint), CSS (stylelint),
puppet (puppet-lint), shell (shellcheck), and several more. For many
codebases, this results in linting being an unpleasantly slow
experience, resulting in even more unpleasant secondary problems like
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
VERSION = "1.0.0"

REQUIRED = [
"pyflakes",
"pycodestyle",
"typing-extensions",
]

Expand Down
50 changes: 2 additions & 48 deletions zulint/linters.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import argparse
import signal
import subprocess
from typing import Callable, Sequence, Tuple
from typing import Callable, Sequence

from zulint.printer import colors, print_err
from zulint.printer import print_err


def run_command(
Expand All @@ -29,48 +28,3 @@ def run_command(
signal_name = f"signal {-p.returncode}"
print_err(name, color, f"{command[0]} terminated by {signal_name}")
return p.returncode


def run_pycodestyle(files: Sequence[str], ignored_rules: Sequence[str]) -> bool:
if len(files) == 0:
return False

command = [
"pycodestyle",
"--ignore={rules}".format(rules=",".join(ignored_rules)),
"--",
*files,
]
return run_command("pep8", next(colors), command) != 0


def run_pyflakes(
files: Sequence[str],
options: argparse.Namespace,
suppress_patterns: Sequence[Tuple[str, str]] = [],
) -> bool:
if len(files) == 0:
return False
failed = False
color = next(colors)
with subprocess.Popen(
["pyflakes", "--", *files],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
) as pyflakes:
# Implied by use of subprocess.PIPE
assert pyflakes.stdout is not None
assert pyflakes.stderr is not None

def suppress_line(line: str) -> bool:
for file_pattern, line_pattern in suppress_patterns:
if file_pattern in line and line_pattern in line:
return True
return False

for ln in pyflakes.stdout.readlines() + pyflakes.stderr.readlines():
if not suppress_line(ln):
print_err("pyflakes", color, ln)
failed = True
return failed

0 comments on commit 9159a9f

Please sign in to comment.