From eb2598400a0dd71fbe100c354b3f1c0b094c65ee Mon Sep 17 00:00:00 2001 From: Matthew Wolter Date: Sun, 12 Apr 2026 04:52:28 -0700 Subject: [PATCH] =?UTF-8?q?G7:=20R05=20=E2=80=94=20widen=20MeshCore.subscr?= =?UTF-8?q?ibe=20callback=20annotation=20to=20match=20dispatcher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: MeshCore.subscribe typed callbacks as Callable[[Event], Coroutine[...]] (async only), while EventDispatcher.subscribe typed them as Callable[[Event], Union[None, asyncio.Future]] (sync or async). Type-checkers flag any sync handler passed through MeshCore.subscribe. Fix: align the annotation to match EventDispatcher's union type; remove unused Coroutine import. Refs: Forensics report finding R05 --- src/meshcore/meshcore.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/meshcore/meshcore.py b/src/meshcore/meshcore.py index bdd0db3..24a1550 100644 --- a/src/meshcore/meshcore.py +++ b/src/meshcore/meshcore.py @@ -1,6 +1,6 @@ import asyncio import logging -from typing import Any, Callable, Coroutine, Dict, Optional, Union +from typing import Any, Callable, Dict, Optional, Union from .events import Event, EventDispatcher, EventType, Subscription from .reader import MessageReader @@ -206,7 +206,7 @@ class MeshCore: def subscribe( self, event_type: Union[EventType, None], - callback: Callable[[Event], Coroutine[Any, Any, None]], + callback: Callable[[Event], Union[None, asyncio.Future]], attribute_filters: Optional[Dict[str, Any]] = None, ) -> Subscription: """