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:
Sebastian Rittau
2018-08-17 17:36:00 +02:00
committed by Jelle Zijlstra
parent a2676ec972
commit 25ac4d6af4
3 changed files with 15 additions and 10 deletions

View File

@@ -14,6 +14,10 @@ from importlib.abc import MetaPathFinder
_T = TypeVar('_T')
# The following type alias are stub-only and do not exist during runtime
_ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType]
_OptExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]]
# ----- sys variables -----
abiflags: str
argv: List[str]
@@ -128,9 +132,7 @@ def _current_frames() -> Dict[int, Any]: ...
def displayhook(value: Optional[int]) -> None: ...
def excepthook(type_: Type[BaseException], value: BaseException,
traceback: TracebackType) -> None: ...
def exc_info() -> Tuple[Optional[Type[BaseException]],
Optional[BaseException],
Optional[TracebackType]]: ...
def exc_info() -> _OptExcInfo: ...
# sys.exit() accepts an optional argument of anything printable
def exit(arg: object = ...) -> NoReturn:
raise SystemExit()