@@ -2,16 +2,7 @@ from collections.abc import Awaitable, Callable, Mapping, Sequence
22from contextlib import AbstractAsyncContextManager , AbstractContextManager
33from threading import Event as ThreadingEvent
44from types import ModuleType
5- from typing import (
6- Any ,
7- ClassVar ,
8- Concatenate ,
9- Literal ,
10- NotRequired ,
11- Required ,
12- TypeAlias ,
13- overload ,
14- )
5+ from typing import Any , ClassVar , Concatenate , Literal , NotRequired , Required , overload
156
167import engineio
178from _typeshed import Incomplete
@@ -27,17 +18,15 @@ from socketio.admin import InstrumentedServer
2718from socketio .msgpack_packet import MsgPackPacket
2819from socketio .server import Server
2920
30- JsonType : TypeAlias = (
21+ type JsonType = (
3122 str | int | float | bool | None | Sequence [JsonType ] | Mapping [str , JsonType ]
3223)
33- DataType : TypeAlias = str | bytes | Sequence [JsonType ] | Mapping [str , JsonType ]
34- TransportType : TypeAlias = Literal ["websocket" , "polling" ]
35- SocketIOModeType : TypeAlias = Literal ["development" , "production" ]
36- SyncAsyncModeType : TypeAlias = Literal [
37- "eventlet" , "gevent_uwsgi" , "gevent" , "threading"
38- ]
39- AsyncAsyncModeType : TypeAlias = Literal ["aiohttp" , "sanic" , "tornado" , "asgi" ]
40- SerializerType : TypeAlias = Literal ["default" , "msgpack" ]
24+ type DataType = str | bytes | Sequence [JsonType ] | Mapping [str , JsonType ]
25+ type TransportType = Literal ["websocket" , "polling" ]
26+ type SocketIOModeType = Literal ["development" , "production" ]
27+ type SyncAsyncModeType = Literal ["eventlet" , "gevent_uwsgi" , "gevent" , "threading" ]
28+ type AsyncAsyncModeType = Literal ["aiohttp" , "sanic" , "tornado" , "asgi" ]
29+ type SerializerType = Literal ["default" , "msgpack" ]
4130
4231class SessionContextManager (AbstractContextManager [Socket ]):
4332 server : Server [Any ]
@@ -225,27 +214,25 @@ class CustomMsgPackPacket(MsgPackPacket):
225214
226215## handlers
227216
228- ServerConnectHandler : TypeAlias = Callable [[str , dict [str , Any ]], Any ]
229- ServerConnectHandlerWithData : TypeAlias = Callable [[str , dict [str , Any ], Any ], Any ]
230- ServerDisconnectHandler : TypeAlias = Callable [[str , engineio .Server .reason ], Any ]
231- ServerDisconnectLegacyHandler : TypeAlias = Callable [[str ], Any ]
232- ClientConnectHandler : TypeAlias = Callable [[], Any ]
233- ClientDisconnectHandler : TypeAlias = Callable [[engineio .Client .reason ], Any ]
234- ClientDisconnectLegacyHandler : TypeAlias = Callable [[], Any ]
235- ClientConnectErrorHandler : TypeAlias = Callable [[Any ], Any ]
236- CatchAllHandler : TypeAlias = Callable [[str , str , Any ], Any ]
237- SyncEventHandlerWithSid : TypeAlias = Callable [
217+ type ServerConnectHandler = Callable [[str , dict [str , Any ]], Any ]
218+ type ServerConnectHandlerWithData = Callable [[str , dict [str , Any ], Any ], Any ]
219+ type ServerDisconnectHandler = Callable [[str , engineio .Server .reason ], Any ]
220+ type ServerDisconnectLegacyHandler = Callable [[str ], Any ]
221+ type ClientConnectHandler = Callable [[], Any ]
222+ type ClientDisconnectHandler = Callable [[engineio .Client .reason ], Any ]
223+ type ClientDisconnectLegacyHandler = Callable [[], Any ]
224+ type ClientConnectErrorHandler = Callable [[Any ], Any ]
225+ type CatchAllHandler = Callable [[str , str , Any ], Any ]
226+ type SyncEventHandlerWithSid = Callable [
238227 Concatenate [str , ...], DataType | tuple [DataType , ...] | None
239228]
240- SyncEventHandlerWithoutSid : TypeAlias = Callable [
241- [], DataType | tuple [DataType , ...] | None
242- ]
243- SyncEventHandler : TypeAlias = SyncEventHandlerWithSid | SyncEventHandlerWithoutSid
244- AsyncEventHandlerWithSid : TypeAlias = Callable [
229+ type SyncEventHandlerWithoutSid = Callable [[], DataType | tuple [DataType , ...] | None ]
230+ type SyncEventHandler = SyncEventHandlerWithSid | SyncEventHandlerWithoutSid
231+ type AsyncEventHandlerWithSid = Callable [
245232 Concatenate [str , ...], Awaitable [DataType | tuple [DataType , ...] | None ]
246233]
247- AsyncEventHandlerWithoutSid : TypeAlias = Callable [
234+ type AsyncEventHandlerWithoutSid = Callable [
248235 [], Awaitable [DataType | tuple [DataType , ...] | None ]
249236]
250- AsyncEventHandler : TypeAlias = AsyncEventHandlerWithSid | AsyncEventHandlerWithoutSid
251- EventHandler : TypeAlias = SyncEventHandler | AsyncEventHandler
237+ type AsyncEventHandler = AsyncEventHandlerWithSid | AsyncEventHandlerWithoutSid
238+ type EventHandler = SyncEventHandler | AsyncEventHandler
0 commit comments