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:
co-authored by
Claude Opus 4.7
parent
a4e6125d28
commit
665cb9b1eb
@@ -91,8 +91,10 @@ async def _poll_astrolabe_search_for_note(
|
||||
)
|
||||
if note_result is not None:
|
||||
logger.info(
|
||||
f"Note {note_id} surfaced in Astrolabe search after {attempts} "
|
||||
f"attempts (~{attempts * 2}s)"
|
||||
"Note %s surfaced in Astrolabe search after %s attempts (~%ss)",
|
||||
note_id,
|
||||
attempts,
|
||||
attempts * 2,
|
||||
)
|
||||
return note_result
|
||||
await anyio.sleep(2)
|
||||
@@ -245,7 +247,7 @@ async def test_chunk_context_endpoint_uses_app_password(
|
||||
"nc_notes_delete_note", {"note_id": note_id}
|
||||
)
|
||||
except Exception as cleanup_err:
|
||||
logger.warning(f"Cleanup failed for note {note_id}: {cleanup_err}")
|
||||
logger.warning("Cleanup failed for note %s: %s", note_id, cleanup_err)
|
||||
await context.close()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user