Format: application/octet-stream
1 # Types to support PEP 3333 (WSGI)
2 #
3 # This module doesn't exist at runtime and neither do the types defined in this
4 # file. They are provided for type checking purposes.
5
6 from sys import _OptExcInfo
7 from typing import Any, Callable, Dict, Iterable, List, Optional, Protocol, Text, Tuple
8
9 class StartResponse(Protocol):
10 def __call__(
11 self, status: str, headers: List[Tuple[str, str]], exc_info: Optional[_OptExcInfo] = ...
12 ) -> Callable[[bytes], Any]: ...
13
14 WSGIEnvironment = Dict[Text, Any]
15 WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]]
16
17 # WSGI input streams per PEP 3333
18 class InputStream(Protocol):
19 def read(self, size: int = ...) -> bytes: ...
20 def readline(self, size: int = ...) -> bytes: ...
21 def readlines(self, hint: int = ...) -> List[bytes]: ...
22 def __iter__(self) -> Iterable[bytes]: ...
23
24 # WSGI error streams per PEP 3333
25 class ErrorStream(Protocol):
26 def flush(self) -> None: ...
27 def write(self, s: str) -> None: ...
28 def writelines(self, seq: List[str]) -> None: ...
29
30 class _Readable(Protocol):
31 def read(self, size: int = ...) -> bytes: ...
32
33 # Optional file wrapper in wsgi.file_wrapper
34 class FileWrapper(Protocol):
35 def __call__(self, file: _Readable, block_size: int = ...) -> Iterable[bytes]: ...
36