1+ from _typeshed import Unused
12from typing import Any
23
34from asgiref .typing import WebSocketConnectEvent , WebSocketDisconnectEvent , WebSocketReceiveEvent
4- from channels .consumer import AsyncConsumer , SyncConsumer , _ChannelScope
5- from channels .layers import BaseChannelLayer
5+ from channels .consumer import AsyncConsumer , SyncConsumer
66
77class WebsocketConsumer (SyncConsumer ):
88 groups : list [str ] | None
9- scope : _ChannelScope
10- channel_name : str
11- channel_layer : BaseChannelLayer
12- channel_receive : Any
13- base_send : Any
149
15- def __init__ (self , * args : Any , ** kwargs : Any ) -> None : ...
10+ def __init__ (self , * args : Unused , ** kwargs : Unused ) -> None : ...
1611 def websocket_connect (self , message : WebSocketConnectEvent ) -> None : ...
1712 def connect (self ) -> None : ...
1813 def accept (self , subprotocol : str | None = None , headers : list [tuple [str , str ]] | None = None ) -> None : ...
@@ -27,22 +22,20 @@ class WebsocketConsumer(SyncConsumer):
2722
2823class JsonWebsocketConsumer (WebsocketConsumer ):
2924 def receive (self , text_data : str | None = None , bytes_data : bytes | None = None , ** kwargs : Any ) -> None : ...
25+ # content is typed as Any to match json.loads() return type - JSON can represent
26+ # various Python types (dict, list, str, int, float, bool, None)
3027 def receive_json (self , content : Any , ** kwargs : Any ) -> None : ...
28+ # content is typed as Any to match json.dumps() input type - accepts any JSON-serializable object
3129 def send_json (self , content : Any , close : bool = False ) -> None : ...
3230 @classmethod
33- def decode_json (cls , text_data : str ) -> Any : ...
31+ def decode_json (cls , text_data : str ) -> Any : ... # Returns Any like json.loads()
3432 @classmethod
35- def encode_json (cls , content : Any ) -> str : ...
33+ def encode_json (cls , content : Any ) -> str : ... # Accepts Any like json.dumps()
3634
3735class AsyncWebsocketConsumer (AsyncConsumer ):
3836 groups : list [str ] | None
39- scope : _ChannelScope
40- channel_name : str
41- channel_layer : BaseChannelLayer
42- channel_receive : Any
43- base_send : Any
4437
45- def __init__ (self , * args : Any , ** kwargs : Any ) -> None : ...
38+ def __init__ (self , * args : Unused , ** kwargs : Unused ) -> None : ...
4639 async def websocket_connect (self , message : WebSocketConnectEvent ) -> None : ...
4740 async def connect (self ) -> None : ...
4841 async def accept (self , subprotocol : str | None = None , headers : list [tuple [str , str ]] | None = None ) -> None : ...
@@ -57,9 +50,12 @@ class AsyncWebsocketConsumer(AsyncConsumer):
5750
5851class AsyncJsonWebsocketConsumer (AsyncWebsocketConsumer ):
5952 async def receive (self , text_data : str | None = None , bytes_data : bytes | None = None , ** kwargs : Any ) -> None : ...
53+ # content is typed as Any to match json.loads() return type - JSON can represent
54+ # various Python types (dict, list, str, int, float, bool, None)
6055 async def receive_json (self , content : Any , ** kwargs : Any ) -> None : ...
56+ # content is typed as Any to match json.dumps() input type - accepts any JSON-serializable object
6157 async def send_json (self , content : Any , close : bool = False ) -> None : ...
6258 @classmethod
63- async def decode_json (cls , text_data : str ) -> Any : ...
59+ async def decode_json (cls , text_data : str ) -> Any : ... # Returns Any like json.loads()
6460 @classmethod
65- async def encode_json (cls , content : Any ) -> str : ...
61+ async def encode_json (cls , content : Any ) -> str : ... # Accepts Any like json.dumps()
0 commit comments