fix(tests): annotate extra= log attrs for mypy in EHBP finalize tests

mypy flags each `record.<field>` access as attr-defined: the FINALIZE fields
are attached via logging's `extra=` payload, which the stdlib LogRecord stub
does not declare. Annotate the assertions with `# type: ignore[attr-defined]`,
matching the convention already used for the same pattern elsewhere (e.g.
tests/unit/test_client_app_logging.py:105).

Unblocks the backend-test jobs, which stopped at mypy before reaching pytest.
This commit is contained in:
redshift
2026-09-17 20:10:44 +02:00
parent 74bfd89ce5
commit ddad44a8da
+12 -11
View File
@@ -171,13 +171,14 @@ async def test_finalize_actual_cost_payment_logs_cache_tokens(
] ]
assert len(finalize_records) == 1 assert len(finalize_records) == 1
record = finalize_records[0] record = finalize_records[0]
assert record.finalize_type == "ehbp_usage" # finalize_type/input_tokens/... are attached via logging's extra= payload.
assert record.input_tokens == 5 assert record.finalize_type == "ehbp_usage" # type: ignore[attr-defined]
assert record.output_tokens == 20 assert record.input_tokens == 5 # type: ignore[attr-defined]
assert record.cache_read_input_tokens == 64 assert record.output_tokens == 20 # type: ignore[attr-defined]
assert record.cache_creation_input_tokens == 0 assert record.cache_read_input_tokens == 64 # type: ignore[attr-defined]
assert record.cache_read_msats == 12 assert record.cache_creation_input_tokens == 0 # type: ignore[attr-defined]
assert record.cache_creation_msats == 0 assert record.cache_read_msats == 12 # type: ignore[attr-defined]
assert record.cache_creation_msats == 0 # type: ignore[attr-defined]
@pytest.mark.asyncio @pytest.mark.asyncio
@@ -206,10 +207,10 @@ async def test_finalize_actual_cost_payment_logs_zero_cache_when_absent(
) )
record = next(record for record in records if record.getMessage() == "FINALIZE") record = next(record for record in records if record.getMessage() == "FINALIZE")
assert record.cache_read_input_tokens == 0 assert record.cache_read_input_tokens == 0 # type: ignore[attr-defined]
assert record.cache_creation_input_tokens == 0 assert record.cache_creation_input_tokens == 0 # type: ignore[attr-defined]
assert record.cache_read_msats == 0 assert record.cache_read_msats == 0 # type: ignore[attr-defined]
assert record.cache_creation_msats == 0 assert record.cache_creation_msats == 0 # type: ignore[attr-defined]
@pytest.mark.asyncio @pytest.mark.asyncio