Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions stubs/gunicorn/gunicorn/asgi/protocol.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
from _typeshed import Incomplete
from collections.abc import Iterable
from typing import Final
from typing import Final, Literal, TypedDict, type_check_only
from typing_extensions import NotRequired

from gunicorn.asgi.parser import CallbackRequest
from gunicorn.config import Config
Expand Down Expand Up @@ -31,6 +31,12 @@ class ASGIResponseInfo:

def __init__(self, status: str | int, headers: Iterable[tuple[str | bytes, str | bytes]], sent: int) -> None: ...

@type_check_only
class _BodyReceieverReceiveReturnType(TypedDict):
type: Literal["http.disconnect", "http.request"]
body: NotRequired[bytes]
more_body: NotRequired[bool]

class BodyReceiver:
__slots__ = ("_chunks", "_complete", "_body_finished", "_closed", "_waiter", "request", "protocol")
request: CallbackRequest
Expand All @@ -40,7 +46,7 @@ class BodyReceiver:
def feed(self, chunk: bytes) -> None: ...
def set_complete(self) -> None: ...
def signal_disconnect(self) -> None: ...
async def receive(self) -> dict[str, Incomplete]: ... # TODO: Use TypedDict
async def receive(self) -> _BodyReceieverReceiveReturnType: ...

class ASGIProtocol(asyncio.Protocol):
worker: ASGIWorker
Expand Down
Loading