G7: R05 — widen MeshCore.subscribe callback annotation to match dispatcher

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
This commit is contained in:
Matthew Wolter 2026-04-12 04:52:28 -07:00
parent 168e613ed7
commit eb2598400a

View file

@ -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:
"""