From a75bfdbbcd02415a35b32da1046ecaecf398b80f Mon Sep 17 00:00:00 2001 From: Tyson Smith Date: Thu, 6 Jun 2024 17:19:18 -0700 Subject: [PATCH] [ci] Update linters --- .pre-commit-config.yaml | 18 +++++++++--------- grizzly/common/status_reporter.py | 2 +- loki/loki.py | 8 +++++++- loki/test_loki.py | 5 +++-- sapphire/__init__.py | 1 + sapphire/conftest.py | 1 + sapphire/test_connection_manager.py | 1 + sapphire/test_job.py | 1 + sapphire/test_sapphire.py | 1 + sapphire/test_worker.py | 1 + tox.ini | 2 +- 11 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bc6d90a7..313fa51c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/asottile/yesqa @@ -8,20 +8,20 @@ repos: hooks: - id: yesqa - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.15.2 hooks: - id: pyupgrade args: ['--py38-plus'] - repo: https://github.com/ambv/black - rev: 23.11.0 + rev: 24.4.2 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-added-large-files - id: check-ast @@ -41,16 +41,16 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell exclude_types: [json] - repo: https://github.com/marco-c/taskcluster_yml_validator - rev: v0.0.10 + rev: v0.0.11 hooks: - id: taskcluster_yml - - repo: https://github.com/MozillaSecurity/orion - rev: v0.0.7 + - repo: https://github.com/MozillaSecurity/orion-ci + rev: v0.0.8 hooks: - id: orion_ci - repo: meta diff --git a/grizzly/common/status_reporter.py b/grizzly/common/status_reporter.py index d8097998..231c3ac4 100644 --- a/grizzly/common/status_reporter.py +++ b/grizzly/common/status_reporter.py @@ -80,7 +80,7 @@ def from_file( ignore_kbi: Skip/ignore KeyboardInterrupt. Returns: - TracebackReport containing data from givin log file. + TracebackReport containing data from given log file. """ token = b"Traceback (most recent call last):" assert len(token) < cls.READ_LIMIT diff --git a/loki/loki.py b/loki/loki.py index b811b5da..2b40f1eb 100644 --- a/loki/loki.py +++ b/loki/loki.py @@ -66,7 +66,7 @@ def _fuzz_data(in_data: bytes, byte_order: str) -> bytes: fuzz_op = randint(0, 4) if fuzz_op == 0: # boundary - out_data = (2 ** randint(2, data_size * 8)) + randint(-2, 2) + out_data: int = (2 ** randint(2, data_size * 8)) + randint(-2, 2) elif fuzz_op == 1: # arithmetic out_data = unpack(pack_unit, in_data)[0] + randint(-10, 10) elif fuzz_op == 2: # interesting byte, short or int @@ -80,6 +80,12 @@ def _fuzz_data(in_data: bytes, byte_order: str) -> bytes: out_data = randint(1, 0x1FFF) * 8 elif data_size == 4: # multiple of 8 out_data = randint(1, 0x1FFFFFFF) * 8 + else: # pragma: no cover + # this should be unreachable + raise RuntimeError(f"Unsupported data size: {data_size}") + else: # pragma: no cover + # this should be unreachable + raise AssertionError(f"Invalid fuzz op: {fuzz_op}") return pack(pack_unit, out_data & mask) diff --git a/loki/test_loki.py b/loki/test_loki.py index 7fb2e1c0..da1892e7 100644 --- a/loki/test_loki.py +++ b/loki/test_loki.py @@ -135,15 +135,16 @@ def test_loki_fuzz_02(mocker): def test_loki_stress_01(): """test Loki._fuzz_data() with random input""" orders = ("<", ">") - sizes = (1, 2, 4) for _ in range(3000): - size = choice(sizes) + size = choice((1, 2, 4)) if size == 1: in_data = pack("B", getrandbits(8)) elif size == 2: in_data = pack("H", getrandbits(16)) elif size == 4: in_data = pack("I", getrandbits(32)) + else: + raise AssertionError(f"invalid size: {size}") assert len(Loki._fuzz_data(in_data, choice(orders))) == size diff --git a/sapphire/__init__.py b/sapphire/__init__.py index 6c7815bc..de8b6469 100644 --- a/sapphire/__init__.py +++ b/sapphire/__init__.py @@ -1,6 +1,7 @@ """ Sapphire HTTP server """ + # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. diff --git a/sapphire/conftest.py b/sapphire/conftest.py index 9eb44b84..d0205aac 100644 --- a/sapphire/conftest.py +++ b/sapphire/conftest.py @@ -1,6 +1,7 @@ """ Sapphire unit test fixtures """ + import socket from hashlib import sha1 from http.client import BadStatusLine diff --git a/sapphire/test_connection_manager.py b/sapphire/test_connection_manager.py index af168b86..cab5b0bc 100644 --- a/sapphire/test_connection_manager.py +++ b/sapphire/test_connection_manager.py @@ -1,6 +1,7 @@ """ ConnectionManager unit tests """ + # pylint: disable=protected-access from itertools import count diff --git a/sapphire/test_job.py b/sapphire/test_job.py index 6ef880af..cf96a733 100644 --- a/sapphire/test_job.py +++ b/sapphire/test_job.py @@ -1,6 +1,7 @@ """ Job unit tests """ + # pylint: disable=protected-access from pathlib import Path from platform import system diff --git a/sapphire/test_sapphire.py b/sapphire/test_sapphire.py index a6858b8b..d8e1f252 100644 --- a/sapphire/test_sapphire.py +++ b/sapphire/test_sapphire.py @@ -1,6 +1,7 @@ """ Sapphire unit tests """ + # pylint: disable=protected-access import socket diff --git a/sapphire/test_worker.py b/sapphire/test_worker.py index 9e73ee85..594e8ebe 100644 --- a/sapphire/test_worker.py +++ b/sapphire/test_worker.py @@ -1,6 +1,7 @@ """ Sapphire unit tests """ + # pylint: disable=protected-access import socket diff --git a/tox.ini b/tox.ini index 021aee5e..055c5b1f 100644 --- a/tox.ini +++ b/tox.ini @@ -48,7 +48,7 @@ usedevelop = true commands = pylint -j 0 {posargs} deps = - pylint==3.0.2 + pylint==3.2.3 usedevelop = true [testenv:pypi]