mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-09 11:11:26 +08:00
Implement StartResponse using a protocol (#2392)
* Add ExcInfo and OptExcInfo type aliases * Implement StartResponse using a protocol * Mark stub-only types with an underscore * Remove wrong TODO note python/mypy#1178 is about variable-length tuples, while exc_info() always returns a tuple with length 3. Ideally, exc_info() would return Union[Tuple[Type[_E], _E, TracebackType], Tuple[None, None, None]], but that is a different issue.
This commit is contained in:
committed by
Jelle Zijlstra
parent
a2676ec972
commit
25ac4d6af4
@@ -15,10 +15,12 @@
|
||||
# you need to use 'WSGIApplication' and not simply WSGIApplication when type
|
||||
# hinting your code. Otherwise Python will raise NameErrors.
|
||||
|
||||
from typing import Callable, Dict, Iterable, List, Any, Text, Protocol
|
||||
from sys import _OptExcInfo
|
||||
from typing import Callable, Dict, Iterable, List, Any, Text, Protocol, Tuple, Optional
|
||||
|
||||
class StartResponse(Protocol):
|
||||
def __call__(self, status: str, headers: List[Tuple[str, str]], exc_info: Optional[_OptExcInfo] = ...) -> Callable[[bytes], Any]: ...
|
||||
|
||||
# (status: str, headers: List[Tuple[str, str]], exc_info = None)
|
||||
StartResponse = Callable[..., Callable[[bytes], Any]]
|
||||
WSGIEnvironment = Dict[Text, Any]
|
||||
WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user