11import asyncio
2- from _typeshed import Incomplete
32from collections .abc import Iterable
4- from typing import Final
3+ from typing import Final , Literal , TypedDict , type_check_only
4+ from typing_extensions import NotRequired
55
66from gunicorn .asgi .parser import CallbackRequest
77from gunicorn .config import Config
@@ -31,6 +31,12 @@ class ASGIResponseInfo:
3131
3232 def __init__ (self , status : str | int , headers : Iterable [tuple [str | bytes , str | bytes ]], sent : int ) -> None : ...
3333
34+ @type_check_only
35+ class _BodyReceieverReceiveReturnType (TypedDict ):
36+ type : Literal ["http.disconnect" , "http.request" ]
37+ body : NotRequired [bytes ]
38+ more_body : NotRequired [bool ]
39+
3440class BodyReceiver :
3541 __slots__ = ("_chunks" , "_complete" , "_body_finished" , "_closed" , "_waiter" , "request" , "protocol" )
3642 request : CallbackRequest
@@ -40,7 +46,7 @@ class BodyReceiver:
4046 def feed (self , chunk : bytes ) -> None : ...
4147 def set_complete (self ) -> None : ...
4248 def signal_disconnect (self ) -> None : ...
43- async def receive (self ) -> dict [ str , Incomplete ] : ... # TODO: Use TypedDict
49+ async def receive (self ) -> _BodyReceieverReceiveReturnType : ...
4450
4551class ASGIProtocol (asyncio .Protocol ):
4652 worker : ASGIWorker
0 commit comments