mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
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:
parent
168e613ed7
commit
eb2598400a
1 changed files with 2 additions and 2 deletions
|
|
@ -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:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue