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
@@ -40,7 +40,7 @@ async def test_search_with_empty_query(nc_mcp_client: ClientSession):
|
||||
# Search with empty query
|
||||
response = await nc_mcp_client.call_tool("nc_notes_search_notes", {"query": ""})
|
||||
|
||||
logger.info(f"Empty search query response: {response}")
|
||||
logger.info("Empty search query response: %s", response)
|
||||
|
||||
# Should return successful response with empty or valid results
|
||||
assert response is not None
|
||||
@@ -54,7 +54,7 @@ async def test_tool_missing_required_parameters(nc_mcp_client: ClientSession):
|
||||
"nc_notes_create_note",
|
||||
{"title": "Test"}, # Missing content and category
|
||||
)
|
||||
logger.info(f"Missing params response: {response}")
|
||||
logger.info("Missing params response: %s", response)
|
||||
|
||||
# Should return error response for missing required parameters
|
||||
assert response is not None
|
||||
@@ -108,7 +108,7 @@ async def test_calendar_missing_calendar_error(nc_mcp_client: ClientSession):
|
||||
},
|
||||
)
|
||||
|
||||
logger.info(f"Non-existent calendar response: {response}")
|
||||
logger.info("Non-existent calendar response: %s", response)
|
||||
|
||||
# Should return structured error response
|
||||
assert response is not None
|
||||
@@ -131,7 +131,7 @@ async def test_webdav_read_missing_file_error(nc_mcp_client: ClientSession):
|
||||
"nc_webdav_read_file", {"path": "non-existent-file.txt"}
|
||||
)
|
||||
|
||||
logger.info(f"Missing file response: {response}")
|
||||
logger.info("Missing file response: %s", response)
|
||||
|
||||
# Should return structured error response
|
||||
assert response is not None
|
||||
@@ -154,7 +154,7 @@ async def test_tables_missing_table_error(nc_mcp_client: ClientSession):
|
||||
"nc_tables_get_schema", {"table_id": 999999}
|
||||
)
|
||||
|
||||
logger.info(f"Missing table response: {response}")
|
||||
logger.info("Missing table response: %s", response)
|
||||
|
||||
# Should return structured error response
|
||||
assert response is not None
|
||||
|
||||
Reference in New Issue
Block a user