lint: Replace pycodestyle and pyflakes with ruff.

https://github.com/charliermarsh/ruff

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2022-10-29 18:07:03 -04:00
committed by Tim Abbott
parent 05913f5e3a
commit adffad384c
14 changed files with 50 additions and 121 deletions

View File

@@ -1,10 +0,0 @@
from typing import List
from zulint.linters import run_command
from zulint.printer import colors
def check_pep8(files: List[str]) -> bool:
if not files:
return False
return run_command("pep8", next(colors), ["pycodestyle", "--", *files]) != 0

View File

@@ -1,34 +0,0 @@
import argparse
from typing import List
from zulint.linters import run_pyflakes
def check_pyflakes(files: List[str], options: argparse.Namespace) -> bool:
suppress_patterns = [
("scripts/lib/pythonrc.py", "imported but unused"),
# LDAP imports are necessary for docker-zulip.
("zproject/prod_settings_template.py", "imported but unused"),
# Our ipython startup pythonrc file intentionally imports *
("scripts/lib/pythonrc.py", " import *' used; unable to detect undefined names"),
(
"zerver/views/realm.py",
"local variable 'message_retention_days' is assigned to but never used",
),
(
"zerver/views/realm.py",
"local variable 'message_content_delete_limit_seconds' is assigned to but never used",
),
("settings.py", "settings import *' used; unable to detect undefined names"),
(
"settings.py",
"'from .prod_settings_template import *' used; unable to detect undefined names",
),
("settings.py", "settings.*' imported but unused"),
("settings.py", "'.prod_settings_template.*' imported but unused"),
# Sphinx adds `tags` specially to the environment when running conf.py.
("docs/conf.py", "undefined name 'tags'"),
]
if options.full:
suppress_patterns = []
return run_pyflakes(files, options, suppress_patterns)