Skip to content

Commit

Permalink
[nyx] Update linters
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwartzentruber committed Nov 15, 2024
1 parent 9cdf245 commit cb18049
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
33 changes: 18 additions & 15 deletions services/nyx/nyx_ipc_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@
from pathlib import Path, PurePosixPath
from random import choice, randint
from subprocess import TimeoutExpired, check_call, run
from typing import Dict, List, Optional, Set, TextIO
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from io import TextIOBase


def run_generic(
args: List[str],
args: list[str],
bindir: Path,
cache_path: Path,
min_msg_size: int,
ignore_message_types: Set[str],
ignore_message_types: set[str],
timeout: int,
) -> Dict[str, int]:
) -> dict[str, int]:
unique_msgs = {}

env = os.environ.copy()
Expand Down Expand Up @@ -54,7 +57,7 @@ def run_generic(
# PBackgroundIDBFactory::Msg_PBackgroundIDBDatabaseConstructor Size: 576
errlines = out.splitlines()
errlines.extend(err.splitlines())
maybe_too_small: Set[str] = set()
maybe_too_small: set[str] = set()
for errline in errlines:
if "[OnIPCMessage]" in errline and "unknown IPC msg name" not in errline:
components = errline.split(" ")
Expand Down Expand Up @@ -86,11 +89,11 @@ def run_generic(
def run_mochitest_local(
bindir: Path,
testenv: Path,
mochitest_args: List[str],
mochitest_args: list[str],
mochitest_cache_path: Path,
min_msg_size: int,
ignore_message_types: Set[str],
) -> Dict[str, int]:
ignore_message_types: set[str],
) -> dict[str, int]:
args = [
str(testenv / "venv" / "bin" / "python"),
"-u",
Expand Down Expand Up @@ -119,8 +122,8 @@ def run_file_local(
local_file: Path,
local_file_cache_path: Path,
min_msg_size: int,
ignore_message_types,
) -> Dict[str, int]:
ignore_message_types: set[str],
) -> dict[str, int]:
prefs_file = sharedir / "prefs.js"
firefox_path = bindir / "firefox"

Expand All @@ -139,7 +142,7 @@ def run_file_local(
)


def add_nyx_env_vars(fd: TextIO):
def add_nyx_env_vars(fd: TextIOBase) -> None:
"""Add env vars prefixed MOZ_FUZZ_ to config.sh which is
passed through to the QEMU target.
"""
Expand All @@ -156,9 +159,9 @@ def run_afl(
afldir: Path,
sharedir: Path,
runtime: int,
custom_mutator: Optional[str],
custom_mutator: str | None,
debug: bool,
):
) -> None:
env = os.environ.copy()

# env["AFL_NO_UI"] = "1"
Expand Down Expand Up @@ -203,7 +206,7 @@ def run_afl(
shutil.rmtree(afldir)


def main(args: Optional[List[str]] = None) -> int:
def main(args: list[str] | None = None) -> int:
"""Command line options."""

# setup argparser
Expand Down Expand Up @@ -329,7 +332,7 @@ def main(args: Optional[List[str]] = None) -> int:
with opts.single_ignore_messages.open() as fd:
ignore_message_types |= {line.strip() for line in fd}

mochitest_dir: Optional[Path] = None
mochitest_dir: Path | None = None
if opts.mochitest is not None:
if opts.mochitest == "plain":
mochitest_dir = testenv / "tests" / "mochitest" / "tests"
Expand Down
5 changes: 2 additions & 3 deletions services/nyx/nyx_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
from google.cloud import storage


def ncpu():
def ncpu() -> None:
print(psutil.cpu_count(logical=False))



def gcs_cat():
def gcs_cat() -> None:
parser = ArgumentParser(prog="gcs-cat")
parser.add_argument("bucket")
parser.add_argument("path")
Expand Down
17 changes: 8 additions & 9 deletions services/nyx/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
target-version = ["py38"]

[[tool.mypy.overrides]]
module = [
"setuptools",
]
[tool.mypy]
ignore_missing_imports = true
strict = true
show_error_codes = true
warn_unused_ignores = false

[tool.pylint.format]
max-line-length = 88

[tool.ruff]
ignore = []
line-length = 88
target-version = "py39"

[tool.ruff.lint]
ignore = []
select = [
# flake8
"E",
Expand All @@ -29,4 +29,3 @@ select = [
# includes yesqa
"RUF",
]
target-version = "py38"
7 changes: 3 additions & 4 deletions services/nyx/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ tox_pip_extensions_ext_venv_update = true

[testenv:lint]
deps =
black==v23.11.0
mypy==v1.7.1
ruff==v0.1.6
mypy==v1.13.0
ruff==v0.7.4
usedevelop = true
allowlist_externals =
bash
commands =
ruff format --diff {toxinidir}
ruff check --fix --exit-non-zero-on-fix {toxinidir}
black --diff --check {toxinidir}
mypy --install-types --non-interactive {toxinidir}

0 comments on commit cb18049

Please sign in to comment.