From: Tamir Duberstein <tamird@kernel.org>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
Tamir Duberstein <tamird@kernel.org>
Subject: [PATCH patatt 2/7] Add Ruff import checks
Date: Sun, 19 Apr 2026 21:22:22 -0400 [thread overview]
Message-ID: <20260419-stronger-type-checking-v1-2-5c108048d2c7@kernel.org> (raw)
In-Reply-To: <20260419-stronger-type-checking-v1-0-5c108048d2c7@kernel.org>
Run Ruff's default lint rules together with import sorting and the
existing blanket-noqa check.
Sort imports and remove unused test imports so the expanded lint
configuration is green under the local CI script.
Signed-off-by: Tamir Duberstein <tamird@kernel.org>
---
docs/conf.py | 5 +++--
pyproject.toml | 3 ++-
src/patatt/__init__.py | 29 +++++++++++++----------------
tests/conftest.py | 7 +++----
tests/test_validation.py | 7 ++++---
tests/unit/test_byhash.py | 2 +-
| 6 +++---
tests/unit/test_get_algo_keydata.py | 11 +++++------
tests/unit/test_patatt_message.py | 7 +++----
9 files changed, 37 insertions(+), 40 deletions(-)
diff --git a/docs/conf.py b/docs/conf.py
index 042c753..cb0ca38 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -9,13 +9,14 @@ import sys
# Add the source directory to the path for autodoc
sys.path.insert(0, os.path.abspath('../src'))
+# The version info
+from patatt import __VERSION__
+
# -- Project information -----------------------------------------------------
project = 'patatt'
copyright = '2021-2026, Konstantin Ryabitsev'
author = 'Konstantin Ryabitsev'
-# The version info
-from patatt import __VERSION__
version = __VERSION__
release = __VERSION__
diff --git a/pyproject.toml b/pyproject.toml
index a541b01..7583cd4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -52,7 +52,8 @@ version = {attr = "patatt.__VERSION__"}
"share/man/man5" = ["man/patatt.5"]
[tool.ruff.lint]
-select = [
+extend-select = [
+ "I",
"PGH004", # https://docs.astral.sh/ruff/rules/blanket-noqa/
]
flake8-quotes.inline-quotes = "single"
diff --git a/src/patatt/__init__.py b/src/patatt/__init__.py
index 499d820..935da55 100644
--- a/src/patatt/__init__.py
+++ b/src/patatt/__init__.py
@@ -5,27 +5,24 @@
#
__author__ = 'Konstantin Ryabitsev <konstantin@linuxfoundation.org>'
-import sys
-import os
-import re
-
import argparse
-import hashlib
import base64
-import subprocess
+import datetime
+import email.header
+import email.utils
+import hashlib
import logging
+import os
+import re
+import subprocess
+import sys
import tempfile
import time
-import datetime
-import warnings
-
import urllib.parse
-import email.utils
-import email.header
-
-from pathlib import Path
-from typing import Optional, List, Tuple, Dict, Union, Any
+import warnings
from io import BytesIO
+from pathlib import Path
+from typing import Any, Dict, List, Optional, Tuple, Union
GitConfigType = Dict[str, Union[str, List[str]]]
@@ -437,8 +434,8 @@ class DevsigHeader:
def _sign_ed25519(payload: bytes, privkey: bytes) -> Tuple[bytes, bytes]:
global KEYCACHE
try:
- from nacl.signing import SigningKey
from nacl.encoding import Base64Encoder
+ from nacl.signing import SigningKey
except ModuleNotFoundError:
raise RuntimeError('This operation requires PyNaCl libraries')
@@ -456,9 +453,9 @@ class DevsigHeader:
@staticmethod
def _validate_ed25519(sigdata: bytes, pubkey: bytes) -> bytes:
try:
- from nacl.signing import VerifyKey
from nacl.encoding import Base64Encoder
from nacl.exceptions import BadSignatureError
+ from nacl.signing import VerifyKey
except ModuleNotFoundError:
raise RuntimeError('This operation requires PyNaCl libraries')
diff --git a/tests/conftest.py b/tests/conftest.py
index a9c9157..8bb6064 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,13 +1,12 @@
+import base64
+import tempfile
from pathlib import Path
+from typing import Dict, Generator
-import os
-import tempfile
import pytest
-import base64
from patatt import DevsigHeader, PatattMessage
-from typing import Generator, Dict
@pytest.fixture
def sample_email_bytes() -> bytes:
diff --git a/tests/test_validation.py b/tests/test_validation.py
index 61c4ab6..d51be81 100644
--- a/tests/test_validation.py
+++ b/tests/test_validation.py
@@ -1,9 +1,10 @@
-import pytest
import os
-import tempfile
from pathlib import Path
-from patatt import PatattMessage, sign_message, validate_message, RES_VALID
+import pytest
+
+from patatt import RES_VALID, validate_message
+
@pytest.mark.parametrize("sample_file", [
"ed25519-signed.txt",
diff --git a/tests/unit/test_byhash.py b/tests/unit/test_byhash.py
index a24d338..c3fe4d2 100644
--- a/tests/unit/test_byhash.py
+++ b/tests/unit/test_byhash.py
@@ -4,7 +4,7 @@ from pathlib import Path
import pytest
-from patatt import make_byhash_path, make_pkey_path, get_public_key
+from patatt import get_public_key, make_byhash_path, make_pkey_path
class TestMakeByhashPath:
--git a/tests/unit/test_devsig_header.py b/tests/unit/test_devsig_header.py
index 5c5bb06..547593d 100644
--- a/tests/unit/test_devsig_header.py
+++ b/tests/unit/test_devsig_header.py
@@ -1,11 +1,11 @@
-import pytest
import base64
import hashlib
from io import BytesIO
-from typing import Dict
+import pytest
+
+from patatt import DevsigHeader
-from patatt import DevsigHeader, ValidationError, SigningError
class TestDevsigHeader:
diff --git a/tests/unit/test_get_algo_keydata.py b/tests/unit/test_get_algo_keydata.py
index 6f268eb..545f051 100644
--- a/tests/unit/test_get_algo_keydata.py
+++ b/tests/unit/test_get_algo_keydata.py
@@ -1,14 +1,13 @@
-import pytest
+from typing import Callable
+from unittest.mock import MagicMock, patch
-from typing import Any, Callable
-from unittest.mock import patch, MagicMock
+import pytest
from patatt import (
- get_algo_keydata,
- NoKeyError,
- ConfigurationError,
KEYCACHE,
GitConfigType,
+ NoKeyError,
+ get_algo_keydata,
)
diff --git a/tests/unit/test_patatt_message.py b/tests/unit/test_patatt_message.py
index 1422ee7..58338f4 100644
--- a/tests/unit/test_patatt_message.py
+++ b/tests/unit/test_patatt_message.py
@@ -1,10 +1,9 @@
+from typing import Tuple
+
import pytest
-import re
-from io import BytesIO
-from patatt import PatattMessage, ValidationError
+from patatt import PatattMessage
-from typing import Tuple
class TestPatattMessage:
--
2.53.0
next prev parent reply other threads:[~2026-04-20 1:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 1:22 [PATCH patatt 0/7] Harden local checks Tamir Duberstein
2026-04-20 1:22 ` [PATCH patatt 1/7] Add local CI script Tamir Duberstein
2026-04-20 1:22 ` Tamir Duberstein [this message]
2026-04-20 1:22 ` [PATCH patatt 3/7] Add Ruff format check Tamir Duberstein
2026-04-20 1:22 ` [PATCH patatt 4/7] Add pyright strict checks Tamir Duberstein
2026-04-20 1:22 ` [PATCH patatt 5/7] Add ty checks Tamir Duberstein
2026-04-20 1:22 ` [PATCH patatt 6/7] Reduce dictionary lookups Tamir Duberstein
2026-04-20 1:22 ` [PATCH patatt 7/7] Import PyNaCl unconditionally Tamir Duberstein
2026-04-27 20:20 ` [PATCH patatt 0/7] Harden local checks Tamir Duberstein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260419-stronger-type-checking-v1-2-5c108048d2c7@kernel.org \
--to=tamird@kernel.org \
--cc=konstantin@linuxfoundation.org \
--cc=tools@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox