From 6cfea42772118fce3872ba549bf19ba06d95c658 Mon Sep 17 00:00:00 2001
From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com>
Date: Tue, 17 Nov 2026 14:15:26 +0100
Subject: [PATCH 1/4] style(python): format and lint this repository's Python
with ruff
Pin ruff in .mise.toml, add a ruff.toml (120 columns, Python 3.8 target for
the ai-commits-badge action) and apply ruff format plus the ruff check fixes,
so the ruff linter added to lint.yml next passes here.
Refs #539
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
---
.mise.toml | 1 +
actions/ai-commits-badge/ai_commits_badge.py | 81 +++++++---
ruff.toml | 8 +
.../config-sync/renovate-extends-preset.py | 9 +-
scripts/lint-inline-scripts.py | 31 ++--
tests/ai-commits-badge.py | 74 ++++++---
tests/app-key-confinement.py | 50 ++++--
tests/issue-labeler-config.py | 10 +-
tests/lint-include.py | 32 ++--
tests/lint-inline-scripts.py | 6 +-
tests/pr-labeler-config.py | 8 +-
tests/workflow-job-conditions.py | 151 +++++++++++++-----
tests/workflow-script-fetch.py | 14 +-
13 files changed, 324 insertions(+), 151 deletions(-)
create mode 100644 ruff.toml
diff --git a/.mise.toml b/.mise.toml
index 409e423e..98df7a9c 100644
--- a/.mise.toml
+++ b/.mise.toml
@@ -10,6 +10,7 @@ git-cliff = "2.14.2"
"pipx:checkov" = "3.3.30"
"pipx:json5" = "0.17.3"
"pipx:yamllint" = "1.38.0"
+ruff = "0.17.5"
shellcheck = "0.11.0"
shfmt = "3.14.1"
trivy = "0.76.1"
diff --git a/actions/ai-commits-badge/ai_commits_badge.py b/actions/ai-commits-badge/ai_commits_badge.py
index 451e616b..ac094de3 100644
--- a/actions/ai-commits-badge/ai_commits_badge.py
+++ b/actions/ai-commits-badge/ai_commits_badge.py
@@ -5,6 +5,7 @@
Outputs in --out: ai-commits.svg, ai-commits.json (Shields endpoint),
ai-commits-stats.json and ai-commits-card.svg (auto light/dark).
"""
+
import argparse
import json
import re
@@ -34,8 +35,21 @@
]
PURPLE, GREY = "#8250df", "#8c959f"
SPARKLE = "M5 0 6.2 3.8 10 5 6.2 6.2 5 10 3.8 6.2 0 5 3.8 3.8Z"
-VERDANA = {" ": 3.9, "%": 11.9, "/": 4.7, "I": 4.6, "A": 7.5, "i": 3.1, "m": 10.7, "t": 4.3,
- "s": 5.7, "c": 5.7, "o": 6.7, "n": 7.0, "a": 6.6}
+VERDANA = {
+ " ": 3.9,
+ "%": 11.9,
+ "/": 4.7,
+ "I": 4.6,
+ "A": 7.5,
+ "i": 3.1,
+ "m": 10.7,
+ "t": 4.3,
+ "s": 5.7,
+ "c": 5.7,
+ "o": 6.7,
+ "n": 7.0,
+ "a": 6.6,
+}
def text_width(s):
@@ -57,8 +71,11 @@ def ai_tool(identity):
def git(repo_dir, *args):
return subprocess.run(
- ["git", "-C", str(repo_dir), *args], check=True,
- capture_output=True, text=True, encoding="utf-8",
+ ["git", "-C", str(repo_dir), *args],
+ check=True,
+ capture_output=True,
+ text=True,
+ encoding="utf-8",
).stdout
@@ -114,10 +131,12 @@ def tooltip(st, name):
return f"{name}: no commits to measure"
window = f" since {st['since']}" if st["since"] else ""
by_tool = ", ".join(f"{t} {n}" for t, n in st["tools"].items()) or "none"
- return (f"{name}: {st['ai_commits']:,} of {st['commits']:,} commits{window} ({message(st)}) involved AI: "
- f"{st['agent']:,} by an AI agent, {st['coauthored']:,} co-authored with AI, "
- f"{st['unattributed']:,} {NO_ATTRIBUTION}. "
- f"By tool: {by_tool}. Excludes merges and {st['excluded_automation']:,} bot-automation commits.")
+ return (
+ f"{name}: {st['ai_commits']:,} of {st['commits']:,} commits{window} ({message(st)}) involved AI: "
+ f"{st['agent']:,} by an AI agent, {st['coauthored']:,} co-authored with AI, "
+ f"{st['unattributed']:,} {NO_ATTRIBUTION}. "
+ f"By tool: {by_tool}. Excludes merges and {st['excluded_automation']:,} bot-automation commits."
+ )
def badge_svg(st, name, label="AI commits"):
@@ -135,10 +154,12 @@ def badge_svg(st, name, label="AI commits"):
def txt(cx, t):
tl = text_width(t) * 10
- return (f'{escape(t)}'
- f'{escape(t)}')
+ return (
+ f'{escape(t)}'
+ f'{escape(t)}'
+ )
return (
f'