public inbox for tools@linux.kernel.org
 help / color / mirror / Atom feed
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 01/14] Add b4 CI checks and mypy suppressions
Date: Fri, 10 Apr 2026 18:37:52 -0400	[thread overview]
Message-ID: <20260410-harden-type-checking-v1-1-fcf314d9d748@gmail.com> (raw)
In-Reply-To: <20260410-harden-type-checking-v1-0-fcf314d9d748@gmail.com>

Add a repo-local b4 CI check command and helper script that runs mypy
and pytest so review status surfaces local checks in the b4 UI.

Introduce targeted mypy suppressions for current test-only issues so the
baseline is green before tightening types further.

Also add pytest-asyncio so pytest recognizes
asyncio_default_fixture_loop_scope and stops warning about it.

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 .b4-config           |  2 ++
 pyproject.toml       | 14 ++++++++++
 tools/b4-ci-check.py | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 95 insertions(+)

diff --git a/.b4-config b/.b4-config
new file mode 100644
index 0000000..ad41b6b
--- /dev/null
+++ b/.b4-config
@@ -0,0 +1,2 @@
+[b4]
+  review-series-check-cmd = uv run ./tools/b4-ci-check.py
diff --git a/pyproject.toml b/pyproject.toml
index 2353a18..e31a05c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -40,6 +40,7 @@ dev = [
     "build",
     "mypy",
     "pytest",
+    "pytest-asyncio",
     "ruff",
     "types-requests",
 ]
@@ -56,5 +57,18 @@ strict = true
 module = "authheaders"
 ignore_missing_imports = true
 
+[[tool.mypy.overrides]]
+module = [
+    "test_email_utils",
+    "test_formatting",
+    "test_message",
+    "test_thread",
+]
+disable_error_code = ["attr-defined"]
+
+[[tool.mypy.overrides]]
+module = "test_auth_headers"
+disable_error_code = ["unused-ignore"]
+
 [tool.ruff]
 target-version = "py39"
diff --git a/tools/b4-ci-check.py b/tools/b4-ci-check.py
new file mode 100644
index 0000000..a51e19e
--- /dev/null
+++ b/tools/b4-ci-check.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from __future__ import annotations
+
+import json
+import os
+import sys
+from contextlib import redirect_stderr, redirect_stdout
+from dataclasses import dataclass
+from io import StringIO
+from pathlib import Path
+from typing import Callable
+
+import mypy.api
+import pytest
+
+
+@dataclass(frozen=True)
+class Check:
+    tool: str
+    args: list[str]
+    pass_summary: str
+    run: Callable[[list[str]], tuple[str, str, int]]
+
+
+def run_pytest(args: list[str]) -> tuple[str, str, int]:
+    stdout_buffer = StringIO()
+    stderr_buffer = StringIO()
+    with redirect_stdout(stdout_buffer), redirect_stderr(stderr_buffer):
+        status = pytest.main(args)
+    return stdout_buffer.getvalue(), stderr_buffer.getvalue(), status
+
+
+def main() -> None:
+    sys.stdin.buffer.read()
+
+    repo_root = Path(__file__).resolve().parent.parent
+    os.chdir(repo_root)
+    checks = [
+        # Mypy can emit JSON via "--output json", but b4 only renders details
+        # as plain text, so preserving the normal formatter is more readable.
+        Check(
+            tool='mypy',
+            args=['.'],
+            pass_summary='mypy passed',
+            run=mypy.api.run,
+        ),
+        Check(
+            tool='pytest',
+            args=['--durations=0'],
+            pass_summary='pytest passed',
+            run=run_pytest,
+        ),
+    ]
+
+    results: list[dict[str, str | int]] = []
+    for check in checks:
+        stdout, stderr, status = check.run(check.args)
+        details = (stdout + stderr).strip()
+        results.append(
+            {
+                'tool': check.tool,
+                'status': 'pass' if status == 0 else 'fail',
+                'summary': (
+                    check.pass_summary
+                    if status == 0
+                    else f'{check.tool} failed (exit {status})'
+                ),
+                'details': details,
+            }
+        )
+
+    json.dump(results, sys.stdout, indent=2)
+    sys.stdout.write('\n')
+
+
+if __name__ == '__main__':
+    main()

-- 
2.53.0


  reply	other threads:[~2026-04-10 22:37 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 ` Tamir Duberstein [this message]
2026-04-10 22:37 ` [PATCH 02/14] Type make_msg and drop test suppressions Tamir Duberstein
2026-04-10 22:37 ` [PATCH 03/14] Add ruff import checks to b4 CI Tamir Duberstein
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-1-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