Skip to content

Commit

Permalink
Change required return type in callbacks from None to Any (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrslev authored Nov 5, 2024
1 parent 8ef1f88 commit 1ce88c8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions stompman/client.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import asyncio
import inspect
from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine
from collections.abc import AsyncGenerator, Awaitable, Callable
from contextlib import AsyncExitStack, asynccontextmanager
from dataclasses import dataclass, field
from functools import partial
from ssl import SSLContext
from types import TracebackType
from typing import ClassVar, Literal, Self
from typing import Any, ClassVar, Literal, Self

from stompman.config import ConnectionParameters, Heartbeat
from stompman.connection import AbstractConnection, Connection
Expand All @@ -30,8 +30,8 @@ class Client:
PROTOCOL_VERSION: ClassVar = "1.2" # https://stomp.github.io/stomp-specification-1.2.html

servers: list[ConnectionParameters] = field(kw_only=False)
on_error_frame: Callable[[ErrorFrame], None] | None = None
on_heartbeat: Callable[[], None] | Callable[[], Awaitable[None]] | None = None
on_error_frame: Callable[[ErrorFrame], Any] | None = None
on_heartbeat: Callable[[], Any] | Callable[[], Awaitable[Any]] | None = None

heartbeat: Heartbeat = field(default=Heartbeat(1000, 1000))
ssl: Literal[True] | SSLContext | None = None
Expand Down Expand Up @@ -146,11 +146,11 @@ async def begin(self) -> AsyncGenerator[Transaction, None]:
async def subscribe(
self,
destination: str,
handler: Callable[[MessageFrame], Coroutine[None, None, None]],
handler: Callable[[MessageFrame], Awaitable[Any]],
*,
ack: AckMode = "client-individual",
headers: dict[str, str] | None = None,
on_suppressed_exception: Callable[[Exception, MessageFrame], None],
on_suppressed_exception: Callable[[Exception, MessageFrame], Any],
suppressed_exception_classes: tuple[type[Exception], ...] = (Exception,),
) -> "Subscription":
subscription = Subscription(
Expand Down
4 changes: 2 additions & 2 deletions stompman/connection_lifespan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections.abc import Callable
from contextlib import suppress
from dataclasses import dataclass
from typing import Protocol
from typing import Any, Protocol
from uuid import uuid4

from stompman.config import ConnectionParameters, Heartbeat
Expand Down Expand Up @@ -37,7 +37,7 @@ class ConnectionLifespan(AbstractConnectionLifespan):
disconnect_confirmation_timeout: int
active_subscriptions: ActiveSubscriptions
active_transactions: ActiveTransactions
set_heartbeat_interval: Callable[[float], None]
set_heartbeat_interval: Callable[[float], Any]

async def _establish_connection(self) -> StompProtocolConnectionIssue | None:
await self.connection.write_frame(
Expand Down
7 changes: 4 additions & 3 deletions stompman/subscription.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Callable, Coroutine
from collections.abc import Awaitable, Callable
from dataclasses import dataclass, field
from typing import Any
from uuid import uuid4

from stompman.connection import AbstractConnection
Expand All @@ -21,9 +22,9 @@ class Subscription:
id: str = field(default_factory=lambda: _make_subscription_id(), init=False) # noqa: PLW0108
destination: str
headers: dict[str, str] | None
handler: Callable[[MessageFrame], Coroutine[None, None, None]]
handler: Callable[[MessageFrame], Awaitable[Any]]
ack: AckMode
on_suppressed_exception: Callable[[Exception, MessageFrame], None]
on_suppressed_exception: Callable[[Exception, MessageFrame], Any]
suppressed_exception_classes: tuple[type[Exception], ...]
_connection_manager: ConnectionManager
_active_subscriptions: ActiveSubscriptions
Expand Down

0 comments on commit 1ce88c8

Please sign in to comment.