From e3e7f4f43c6829a4406823eee3a790fe4b298ebb Mon Sep 17 00:00:00 2001 From: Marc Billow Date: Thu, 6 Aug 2026 02:07:39 +0000 Subject: [PATCH] test: suppress ty's invalid-assignment on the fake-session swap coordinator is explicitly typed as LocalThingsCoordinator here, so ty correctly sees _session's declared type (DtlsCoapSession | None) and flags assigning a FakeObserveSession to it. The fixture's own _connect_session replacement does the same swap without tripping ty, but only because its self parameter is unannotated -- ty has nothing to check the assignment against there. Deliberate here (this is the whole point of the test: substitute a stand-in session), so silenced rather than restructured; ty's --add-ignore confirmed the comment syntax (ty: ignore[...], not the mypy-style type: ignore[...] used elsewhere in this suite, which ty doesn't appear to honor for this rule). --- tests/localthings/test_coordinator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/localthings/test_coordinator.py b/tests/localthings/test_coordinator.py index e77da3b..cc289fc 100644 --- a/tests/localthings/test_coordinator.py +++ b/tests/localthings/test_coordinator.py @@ -772,7 +772,7 @@ async def test_attempt_observe_mode_discards_stale_commit_after_session_swap( other = FakeObserveSession() def _swap_session_mid_wait(subscribed, grace_period_s, success_fraction=None): - coordinator._session = other + coordinator._session = other # ty: ignore[invalid-assignment] return True with patch.object(