From: Tamir Duberstein <tamird@gmail.com>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
Tamir Duberstein <tamird@gmail.com>
Subject: [PATCH 03/14] Add ruff import checks to b4 CI
Date: Fri, 10 Apr 2026 18:37:54 -0400 [thread overview]
Message-ID: <20260410-harden-type-checking-v1-3-fcf314d9d748@gmail.com> (raw)
In-Reply-To: <20260410-harden-type-checking-v1-0-fcf314d9d748@gmail.com>
Run ruff as part of the b4 CI check script and enable import sorting in
Ruff so import ordering regressions show up in the review UI.
Keep Ruff as a subprocess and document the related upstream API
limitation.
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
pyproject.toml | 4 ++--
src/liblore/__init__.py | 1 -
src/liblore/node.py | 3 +--
src/liblore/utils.py | 3 +--
tests/conftest.py | 3 +--
| 1 -
tests/test_email_utils.py | 1 -
tests/test_formatting.py | 3 +--
tests/test_mbox.py | 4 +---
tests/test_node.py | 1 -
tools/b4-ci-check.py | 21 +++++++++++++++++++++
11 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 7c9e1da..38be519 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -57,5 +57,5 @@ strict = true
module = "authheaders"
ignore_missing_imports = true
-[tool.ruff]
-target-version = "py39"
+[tool.ruff.lint]
+extend-select = ["I"]
diff --git a/src/liblore/__init__.py b/src/liblore/__init__.py
index ff4314a..1ffaaeb 100644
--- a/src/liblore/__init__.py
+++ b/src/liblore/__init__.py
@@ -3,7 +3,6 @@
"""liblore — shared library for public-inbox / lore.kernel.org access."""
import email.charset
import email.policy
-
from email.message import EmailMessage
__version__ = '0.7.1'
diff --git a/src/liblore/node.py b/src/liblore/node.py
index 5fb6343..66da1d7 100644
--- a/src/liblore/node.py
+++ b/src/liblore/node.py
@@ -15,11 +15,10 @@ import time
import types
import urllib.parse
from datetime import datetime, timezone
+from email.message import EmailMessage
import requests
-from email.message import EmailMessage
-
from liblore import LibloreError, RemoteError
from liblore.utils import (
get_strict_thread,
diff --git a/src/liblore/utils.py b/src/liblore/utils.py
index 8d485da..e8926c6 100644
--- a/src/liblore/utils.py
+++ b/src/liblore/utils.py
@@ -3,7 +3,6 @@
"""Message parsing, email utilities, threading, and mbox splitting."""
from __future__ import annotations
-from collections.abc import Sequence
import datetime
import email.header
import email.parser
@@ -14,7 +13,7 @@ import logging
import re
import textwrap
import urllib.parse
-
+from collections.abc import Sequence
from email.message import EmailMessage
from liblore import emlpolicy
diff --git a/tests/conftest.py b/tests/conftest.py
index b84fc35..ec8ec80 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -4,12 +4,11 @@ from __future__ import annotations
import email.utils
import textwrap
+from email.message import EmailMessage
from typing import Protocol
import pytest
-from email.message import EmailMessage
-
from liblore import emlpolicy
--git a/tests/test_auth_headers.py b/tests/test_auth_headers.py
index 9edf4cd..9097048 100644
--- a/tests/test_auth_headers.py
+++ b/tests/test_auth_headers.py
@@ -13,7 +13,6 @@ import pytest
from liblore import LibloreError
from liblore.node import LoreNode
-
# =====================================================================
# Import-time validation
# =====================================================================
diff --git a/tests/test_email_utils.py b/tests/test_email_utils.py
index ad8775f..74216d4 100644
--- a/tests/test_email_utils.py
+++ b/tests/test_email_utils.py
@@ -16,7 +16,6 @@ from liblore.utils import (
)
-
class TestMsgGetSubject:
def test_plain_subject(self, make_msg: MsgFactory) -> None:
msg = make_msg(subject='Just a plain subject')
diff --git a/tests/test_formatting.py b/tests/test_formatting.py
index a13593e..cb3cf80 100644
--- a/tests/test_formatting.py
+++ b/tests/test_formatting.py
@@ -2,10 +2,9 @@
"""Tests for email formatting and thread minimization."""
from __future__ import annotations
-import pytest
-
from email.message import EmailMessage
+import pytest
from conftest import MsgFactory
from liblore.utils import (
diff --git a/tests/test_mbox.py b/tests/test_mbox.py
index 3815e3f..9bc2271 100644
--- a/tests/test_mbox.py
+++ b/tests/test_mbox.py
@@ -3,9 +3,9 @@
from __future__ import annotations
import textwrap
-
from email.message import EmailMessage
+from liblore import emlpolicy
from liblore.utils import (
get_clean_msgid,
get_preferred_duplicate,
@@ -15,8 +15,6 @@ from liblore.utils import (
split_mbox_as_bytes,
)
-from liblore import emlpolicy
-
class TestSplitMbox:
def test_splits_two_messages(self, sample_mbox: bytes) -> None:
diff --git a/tests/test_node.py b/tests/test_node.py
index c2e7bf3..54d76d8 100644
--- a/tests/test_node.py
+++ b/tests/test_node.py
@@ -14,7 +14,6 @@ import requests
from liblore import RemoteError
from liblore.node import LoreNode
-
# =====================================================================
# Session management
# =====================================================================
diff --git a/tools/b4-ci-check.py b/tools/b4-ci-check.py
index a51e19e..1bc5de1 100644
--- a/tools/b4-ci-check.py
+++ b/tools/b4-ci-check.py
@@ -5,6 +5,7 @@ from __future__ import annotations
import json
import os
+import subprocess
import sys
from contextlib import redirect_stderr, redirect_stdout
from dataclasses import dataclass
@@ -32,12 +33,32 @@ def run_pytest(args: list[str]) -> tuple[str, str, int]:
return stdout_buffer.getvalue(), stderr_buffer.getvalue(), status
+def run_subprocess(tool: str) -> Callable[[list[str]], tuple[str, str, int]]:
+ def run(args: list[str]) -> tuple[str, str, int]:
+ proc = subprocess.run(
+ [tool, *args],
+ capture_output=True,
+ text=True,
+ )
+ return proc.stdout, proc.stderr, proc.returncode
+
+ return run
+
+
def main() -> None:
sys.stdin.buffer.read()
repo_root = Path(__file__).resolve().parent.parent
os.chdir(repo_root)
checks = [
+ Check(
+ tool='ruff lint',
+ args=['check'],
+ pass_summary='ruff lint passed',
+ # Ruff is invoked as a subprocess due to API limitations:
+ # https://github.com/astral-sh/ruff/issues/659
+ run=run_subprocess('ruff'),
+ ),
# Mypy can emit JSON via "--output json", but b4 only renders details
# as plain text, so preserving the normal formatter is more readable.
Check(
--
2.53.0
next prev parent reply other threads:[~2026-04-10 22:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 22:37 [PATCH 00/14] Harden local type checking and test mocking Tamir Duberstein
2026-04-10 22:37 ` [PATCH 01/14] Add b4 CI checks and mypy suppressions Tamir Duberstein
2026-04-10 22:37 ` [PATCH 02/14] Type make_msg and drop test suppressions Tamir Duberstein
2026-04-10 22:37 ` Tamir Duberstein [this message]
2026-04-10 22:37 ` [PATCH 04/14] Add ruff format check to CI Tamir Duberstein
2026-04-10 22:37 ` [PATCH 05/14] Add pyright strict checks " Tamir Duberstein
2026-04-10 22:37 ` [PATCH 06/14] Replace HTTP session mocks with responses Tamir Duberstein
2026-04-10 22:37 ` [PATCH 07/14] Add ty checks to CI Tamir Duberstein
2026-04-10 22:37 ` [PATCH 08/14] Drop redundant read-only property test Tamir Duberstein
2026-04-10 22:38 ` [PATCH 09/14] Type from_git_config keyword arguments Tamir Duberstein
2026-04-10 22:38 ` [PATCH 10/14] Add authheaders stub and typed callable Tamir Duberstein
2026-04-10 22:38 ` [PATCH 11/14] Replace batch mocks with subclasses Tamir Duberstein
2026-04-10 22:38 ` [PATCH 12/14] Use CompletedProcess in git config tests Tamir Duberstein
2026-04-10 22:38 ` [PATCH 13/14] Update README for uv-based dev checks Tamir Duberstein
2026-04-10 22:38 ` [PATCH 14/14] Add b4 send configuration 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=20260410-harden-type-checking-v1-3-fcf314d9d748@gmail.com \
--to=tamird@gmail.com \
--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