refactor: convert f-string logging to lazy %-style format (G004)

Sweep all 1676 G004 violations across 112 files, converting
`logger.<level>(f"…{x}…")` to `logger.<level>("…%s…", x)`.

Why: ruff rule G004 was added to pyproject.toml to enforce lazy
%-style logging — defers formatting until the log level is enabled
and lets structured log tooling match the unformatted template.

Conversion preserves rendered output byte-for-byte:
- `{x}` → `%s` + `x`
- `{x!r}` / `{x!s}` / `{x!a}` → `%r` / `%s` / `%a`
- Format specs (`{x:.2f}`, `{x:>10}`) → `%s` + `format(x, 'spec')`
  (printf-style specs aren't 1:1 with Python format specs, so we
  delegate to `format()` to keep identical output)
- Literal `%` → `%%`
- Concatenated f-strings (`f"a {x} " "b"`) flattened
- Trailing kwargs (`exc_info=True`) preserved

Verified:
- `uv run ruff check --select G004` → 0 violations
- `uv run ty check -- nextcloud_mcp_server` → passes
- `uv run pytest tests/unit/` → 1010 passed

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-05-13 01:12:17 +02:00
co-authored by Claude Opus 4.7
parent a4e6125d28
commit 665cb9b1eb
112 changed files with 2534 additions and 1859 deletions
+5 -5
View File
@@ -24,7 +24,7 @@ async def test_mcp_todo_complete_workflow(
try:
# 1. Create todo via MCP
logger.info(f"Creating todo in {calendar_name} via MCP")
logger.info("Creating todo in %s via MCP", calendar_name)
tomorrow = datetime.now() + timedelta(days=1)
create_result = await nc_mcp_client.call_tool(
@@ -46,7 +46,7 @@ async def test_mcp_todo_complete_workflow(
result_json = json.loads(result_data)
todo_uid = result_json["uid"]
logger.info(f"Created todo with UID: {todo_uid}")
logger.info("Created todo with UID: %s", todo_uid)
# 2. Verify todo creation via client
todos = await nc_client.calendar.list_todos(calendar_name)
@@ -57,7 +57,7 @@ async def test_mcp_todo_complete_workflow(
assert created_todo["priority"] == 3
# 3. List todos via MCP
logger.info(f"Listing todos in {calendar_name} via MCP")
logger.info("Listing todos in %s via MCP", calendar_name)
list_result = await nc_mcp_client.call_tool(
"nc_calendar_list_todos",
{"calendar_name": calendar_name},
@@ -69,7 +69,7 @@ async def test_mcp_todo_complete_workflow(
assert any(t["uid"] == todo_uid for t in list_data["todos"])
# 4. Update todo via MCP
logger.info(f"Updating todo {todo_uid} via MCP")
logger.info("Updating todo %s via MCP", todo_uid)
update_result = await nc_mcp_client.call_tool(
"nc_calendar_update_todo",
{
@@ -92,7 +92,7 @@ async def test_mcp_todo_complete_workflow(
assert updated_todo["percent_complete"] == 50
# 6. Delete todo via MCP
logger.info(f"Deleting todo {todo_uid} via MCP")
logger.info("Deleting todo %s via MCP", todo_uid)
delete_result = await nc_mcp_client.call_tool(
"nc_calendar_delete_todo",
{"calendar_name": calendar_name, "todo_uid": todo_uid},