test(client-sdk/python): drop redundant exclude_none=True from heartbeat tracker tests (#73 review)#79
Conversation
…tbeat tracker tests (#73 review) The reviewer bot's last comment on PR #76 noted that `model_dump_json(exclude_none=True)` at the five `nc.publish(...)` call sites in `test_heartbeat.py` is now redundant: the `@model_serializer(mode="wrap")` added to `HeartbeatPayload` in commit a724ddb already strips `session` when `None` at the model layer, so the per-call-site flag is dead weight. Removing it makes the test code consistent with how production-side `build_heartbeat_payload` callers already serialize (no `exclude_none` argument), and removes the misleading signal that test authors needed a workaround. `test_encoder_omits_none_session` (added in a724ddb) continues to lock in the omission contract at the model layer, so this purely cosmetic cleanup cannot regress on-wire compliance. Refs #73. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude finished @renerocksai's task in 1m 22s —— View job Review
The change is correct and the rationale holds up under inspection. What I verified: All 5 modified call sites construct The No issues. Ready to merge. |
Refs #73. Follows up on the reviewer-bot's last comment on #76.
Context
a724ddb(currently onmain) fixed the"session": nullre-encode regression by adding@model_serializer(mode="wrap")toHeartbeatPayload, which strips thesessionkey at the model layer whenever its value isNone. The accompanyingtest_encoder_omits_none_sessionlocks that contract in.The reviewer-bot's last comment on #76 noted that with the serializer in place, the per-call-site
model_dump_json(exclude_none=True)calls intests/test_heartbeat.pyare now redundant but harmless — they were originally added as a defensive workaround in9bd6e4bbefore the serializer landed.Quoting the relevant excerpt:
What this PR does
Drops
exclude_none=Truefrom the fivenc.publish(...)call sites inclient-sdk/python/tests/test_heartbeat.py(lines 142, 186, 227, 248, 269). The@model_serializercarries the contract on its own, so the test code is now consistent with how production-sidebuild_heartbeat_payloadcallers already serialize (noexclude_noneargument), and no longer signals that test authors needed a per-call workaround.test_encoder_omits_none_sessioncontinues to assert that re-encoding asession=Nonepayload omits thesessionkey — that's the regression guard for the serializer, and it still passes.Procedural note
The
9bd6e4banda724ddbcommits this PR builds on were unfortunately pushed straight tomainby an earlier Claude Code session by mistake. This PR is the cleanup item flagged on top of that work, going through normal review for once.Test plan
uv run pytest tests/test_heartbeat.py -vinclient-sdk/python/— 9 passed (includingtest_encoder_omits_none_session, which proves the serializer alone is sufficient)uv run pytest(full suite) — 212 passed, includingtest_interop_e2e.pyagainst the TS reference agentuv run ruff check --no-cache .cleanuv run ruff format --check .cleanuv run mypy --no-incremental src tests examplesclean🤖 Generated with Claude Code