Add NoReturn (#811)

* Add NoReturn
This commit is contained in:
David Fisher
2017-01-04 13:38:05 -08:00
committed by Łukasz Langa
parent 93bb4604cb
commit 2cb8e184cc
9 changed files with 22 additions and 9 deletions

View File

@@ -9,6 +9,7 @@ from typing import (
)
import typing
import unittest
from mypy_extensions import NoReturn
# Exports
from __builtin__ import unichr as unichr
@@ -79,7 +80,7 @@ def assertRaisesRegex(self: unittest.TestCase, msg: str = ...) -> Any: ...
def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ...
def assertRegex(self: unittest.TestCase, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: str = ...) -> None: ...
def reraise(tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = ...) -> None: ...
def reraise(tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = ...) -> NoReturn: ...
def exec_(_code_: Union[unicode, types.CodeType], _globs_: Dict[str, Any] = ..., _locs_: Dict[str, Any] = ...): ...
def raise_from(value: BaseException, from_value: BaseException) -> None: ...

View File

@@ -1,6 +1,11 @@
from typing import Dict, Type, TypeVar
from typing import Dict, Type, TypeVar, Union
T = TypeVar('T')
def TypedDict(typename: str, fields: Dict[str, Type[T]]) -> Type[dict]: ...
# Return type that indicates a function does not return.
# This type is equivalent to the None type, but the no-op Union is necessary to
# distinguish the None type from the None value.
NoReturn = Union[None]

View File

@@ -23,6 +23,7 @@ from typing import (
import types
import typing
import unittest
from mypy_extensions import NoReturn
# Exports
from io import StringIO as StringIO, BytesIO as BytesIO
@@ -92,7 +93,7 @@ def assertRegex(self: unittest.TestCase, text: AnyStr, expected_regex: Union[Any
exec_ = exec
def reraise(tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = None) -> None: ...
def reraise(tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = None) -> NoReturn: ...
def raise_from(value: BaseException, from_value: BaseException) -> None: ...
print_ = print