Skip to content

Commit 109c021

Browse files
committed
fix: update types
1 parent e2505da commit 109c021

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

src/socketio-stubs/_types.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from collections.abc import Awaitable, Callable, Mapping, Sequence
22
from contextlib import AbstractAsyncContextManager, AbstractContextManager
33
from threading import Event as ThreadingEvent
44
from types import ModuleType
5-
from typing import Any, Concatenate, Literal, TypeAlias, overload
5+
from typing import Any, ClassVar, Concatenate, Literal, TypeAlias, overload
66

77
import engineio
88
from _typeshed import Incomplete
@@ -13,6 +13,7 @@ from engineio.async_drivers.threading import DaemonThread
1313
from engineio.socket import Socket
1414
from gevent.event import Event as GeventEvent
1515
from socketio.admin import InstrumentedServer
16+
from socketio.msgpack_packet import MsgPackPacket
1617
from socketio.server import Server
1718
from typing_extensions import NotRequired, Required, TypedDict
1819

@@ -208,6 +209,10 @@ class JsonModule(ModuleType):
208209
@staticmethod
209210
def loads(s: str | bytes | bytearray, **kwargs: Any) -> Any: ...
210211

212+
class CustomMsgPackPacket(MsgPackPacket):
213+
dumps_default: ClassVar[Callable[[Any], Any] | None]
214+
ext_hook: ClassVar[Callable[[int, bytes], Any]]
215+
211216
## handlers
212217

213218
ServerConnectHandler: TypeAlias = Callable[[str, dict[str, Any]], Any]

src/socketio-stubs/async_redis_manager.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import logging
22
from typing import Any
33

4+
from redis.asyncio import Redis
5+
from redis.asyncio.client import PubSub as RedisPubSub
46
from socketio._types import RedisArgs
57
from socketio.async_pubsub_manager import AsyncPubSubManager
8+
from valkey.asyncio import Valkey
9+
from valkey.asyncio.client import PubSub as ValkeyPubSub
610

711
def parse_redis_sentinel_url(
812
url: str,
@@ -12,6 +16,9 @@ class AsyncRedisManager(AsyncPubSubManager):
1216
name: str
1317
redis_url: str
1418
redis_options: dict[str, Any]
19+
connected: bool
20+
redis: Redis | Valkey | None
21+
pubsub: RedisPubSub | ValkeyPubSub | None
1522
def __init__(
1623
self,
1724
url: str = ...,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
from collections.abc import Callable
2+
from typing import Any
3+
4+
from socketio._types import CustomMsgPackPacket
15
from socketio.packet import Packet
26
from typing_extensions import Buffer
37

48
class MsgPackPacket(Packet):
59
uses_binary_events: bool
610
def encode(self) -> bytes: ...
711
def decode(self, encoded_packet: Buffer) -> None: ... # pyright: ignore[reportIncompatibleMethodOverride]
12+
@classmethod
13+
def configure(
14+
cls,
15+
dump_default: Callable[[Any], Any] | None = ...,
16+
ext_hook: Callable[[int, bytes], Any] = ...,
17+
) -> type[CustomMsgPackPacket]: ...

src/socketio-stubs/packet.pyi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Literal
1+
from typing import Any, Literal
22

33
from socketio._types import DataType, JsonModule
44
from typing_extensions import Buffer
@@ -43,4 +43,9 @@ class Packet:
4343
def encode(self) -> DataType: ...
4444
def decode(self, encoded_packet: Buffer) -> int: ...
4545
def add_attachment(self, attachment: bytes) -> bool: ...
46-
def reconstruct_binary(self, attachments: list[bytes]) -> None: ...
46+
@classmethod
47+
def reconstruct_binary(cls, data: Any, attachments: list[bytes]) -> None: ...
48+
@classmethod
49+
def deconstruct_binary(cls, data: Any) -> tuple[Any, list[bytes]]: ...
50+
@classmethod
51+
def data_is_binary(cls, data: Any) -> bool: ...

src/socketio-stubs/redis_manager.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import logging
22
from typing import Any
33

4+
from redis import Redis
5+
from redis.client import PubSub as RedisPubSub
46
from socketio._types import RedisArgs
57
from socketio.pubsub_manager import PubSubManager
8+
from valkey import Valkey
9+
from valkey.client import PubSub as ValkeyPubSub
610

711
logger: logging.Logger
812

@@ -14,6 +18,9 @@ class RedisManager(PubSubManager):
1418
name: str
1519
redis_url: str
1620
redis_options: dict[str, Any]
21+
connected: bool
22+
redis: Redis | Valkey | None
23+
pubsub: RedisPubSub | ValkeyPubSub | None
1724
def __init__(
1825
self,
1926
url: str = ...,

0 commit comments

Comments
 (0)