Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pyflakes and pycodestyle integration #39

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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