Skip to content

Commit 882c376

Browse files
committed
fix: client namespace
1 parent 3dcf80d commit 882c376

5 files changed

Lines changed: 13 additions & 8 deletions

File tree

src/socketio-stubs/async_client.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ _P = ParamSpec("_P")
1616

1717
default_logger: logging.Logger
1818

19-
class AsyncClient(BaseClient[Literal[True], engineio.AsyncClient]):
19+
class AsyncClient(
20+
BaseClient[Literal[True], engineio.AsyncClient, AsyncClientNamespace]
21+
):
2022
connection_url: str # pyright: ignore[reportIncompatibleVariableOverride]
2123
connection_headers: dict[str, str] # pyright: ignore[reportIncompatibleVariableOverride]
2224
connection_auth: Any
@@ -85,4 +87,4 @@ class AsyncClient(BaseClient[Literal[True], engineio.AsyncClient]):
8587
self, target: Callable[_P, Awaitable[_T]], *args: _P.args, **kwargs: _P.kwargs
8688
) -> asyncio.Task[_T]: ...
8789
async def sleep(self, seconds: int = ...) -> None: ...
88-
def register_namespace(self, namespace_handler: AsyncClientNamespace) -> None: ... # pyright: ignore[reportIncompatibleMethodOverride]
90+
def register_namespace(self, namespace_handler: AsyncClientNamespace) -> None: ...

src/socketio-stubs/async_namespace.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class AsyncNamespace(BaseServerNamespace[Literal[True]], Generic[_A]):
7575
async def disconnect(self, sid: str, namespace: str | None = ...) -> None: ...
7676

7777
class AsyncClientNamespace(BaseClientNamespace[Literal[True]]):
78-
client: AsyncClient # pyright: ignore[reportIncompatibleVariableOverride]
78+
client: AsyncClient # type: ignore[assignment]
7979
async def trigger_event(self, event: str, *args: Any) -> Any: ...
8080
async def emit(
8181
self,

src/socketio-stubs/base_client.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ from socketio.base_namespace import BaseClientNamespace
2323
from socketio.packet import Packet
2424

2525
_T_co = TypeVar("_T_co", bound=Client | AsyncClient, covariant=True, default=Any)
26+
_T_namespace = TypeVar(
27+
"_T_namespace", bound=BaseClientNamespace[Any], default=BaseClientNamespace[Any]
28+
)
2629
_IsAsyncio = TypeVar("_IsAsyncio", bound=bool, default=Literal[False])
2730
_F = TypeVar("_F", bound=Callable[..., Any])
2831
_F_event = TypeVar("_F_event", bound=EventHandler)
@@ -40,7 +43,7 @@ def signal_handler(sig: int, frame: FrameType | None) -> Any: ...
4043

4144
original_signal_handler: Callable[[int, FrameType | None], Any] | None
4245

43-
class BaseClient(Generic[_IsAsyncio, _T_co]):
46+
class BaseClient(Generic[_IsAsyncio, _T_co, _T_namespace]):
4447
reserved_events: ClassVar[list[str]]
4548
reason: ClassVar[type[engineio.Client.reason]]
4649
reconnection: bool
@@ -126,7 +129,7 @@ class BaseClient(Generic[_IsAsyncio, _T_co]):
126129
def event(self, handler: EventHandler) -> None: ...
127130
@overload
128131
def event(self, namespace: str | None) -> Callable[[_F_event], _F_event]: ...
129-
def register_namespace(self, namespace_handler: BaseClientNamespace) -> None: ...
132+
def register_namespace(self, namespace_handler: _T_namespace) -> None: ...
130133
def get_sid(self, namespace: str | None = ...) -> str | None: ...
131134
def transport(self) -> TransportType: ...
132135
def _engineio_client_class(self) -> type[_T_co]: ...

src/socketio-stubs/client.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ from socketio.packet import Packet
1414
_T = TypeVar("_T")
1515
_P = ParamSpec("_P")
1616

17-
class Client(BaseClient[Literal[False], engineio.Client]):
17+
class Client(BaseClient[Literal[False], engineio.Client, ClientNamespace]):
1818
connection_url: str # pyright: ignore[reportIncompatibleVariableOverride]
1919
connection_headers: dict[str, str] # pyright: ignore[reportIncompatibleVariableOverride]
2020
connection_auth: Any
@@ -83,4 +83,4 @@ class Client(BaseClient[Literal[False], engineio.Client]):
8383
self, target: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs
8484
) -> Thread: ...
8585
def sleep(self, seconds: int = ...) -> None: ...
86-
def register_namespace(self, namespace_handler: ClientNamespace) -> None: ... # pyright: ignore[reportIncompatibleMethodOverride]
86+
def register_namespace(self, namespace_handler: ClientNamespace) -> None: ...

src/socketio-stubs/namespace.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Namespace(BaseServerNamespace[Literal[False]], Generic[_A]):
6969
def disconnect(self, sid: str, namespace: str | None = ...) -> None: ...
7070

7171
class ClientNamespace(BaseClientNamespace[Literal[False]]):
72-
client: Client # pyright: ignore[reportIncompatibleVariableOverride]
72+
client: Client # type: ignore[assignment]
7373
def trigger_event(self, event: str, *args: Any) -> Any: ...
7474
def emit(
7575
self,

0 commit comments

Comments
 (0)