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
@@ -55,7 +55,7 @@ class CustomHTTPProcessor(DocumentProcessor):
self._name = name
self._supported_types = supported_types or set()
logger.info(f"Initialized CustomHTTPProcessor: {name} -> {api_url}")
logger.info("Initialized CustomHTTPProcessor: %s -> %s", name, api_url)
@property
def name(self) -> str:
@@ -114,7 +114,9 @@ class CustomHTTPProcessor(DocumentProcessor):
metadata = result.get("metadata", {})
logger.debug(
f"Custom processor '{self.name}' extracted {len(text)} characters"
"Custom processor '%s' extracted %s characters",
self.name,
len(text),
)
return ProcessingResult(
@@ -125,10 +127,10 @@ class CustomHTTPProcessor(DocumentProcessor):
)
except httpx.HTTPError as e:
logger.error(f"Custom processor '{self.name}' HTTP error: {e}")
logger.error("Custom processor '%s' HTTP error: %s", self.name, e)
raise ProcessorError(f"API call failed: {str(e)}") from e
except Exception as e:
logger.error(f"Custom processor '{self.name}' failed: {e}")
logger.error("Custom processor '%s' failed: %s", self.name, e)
raise ProcessorError(f"Processing failed: {str(e)}") from e
async def health_check(self) -> bool:
@@ -146,5 +148,7 @@ class CustomHTTPProcessor(DocumentProcessor):
)
return response.status_code < 500
except Exception as e:
logger.warning(f"Custom processor '{self.name}' health check failed: {e}")
logger.warning(
"Custom processor '%s' health check failed: %s", self.name, e
)
return False