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

@@ -10,6 +10,7 @@ from typing import (
from abc import abstractmethod, ABCMeta
from types import TracebackType
import sys
from mypy_extensions import NoReturn
# Note that names imported above are not automatically made visible via the
# implicit builtins import.
@@ -697,7 +698,7 @@ def eval(source: str, globals: Dict[str, Any] = None,
locals: Mapping[str, Any] = None) -> Any: ... # TODO code object as source
def exec(object: str, globals: Dict[str, Any] = None,
locals: Mapping[str, Any] = None) -> Any: ... # TODO code object as source
def exit(code: int = None) -> None: ...
def exit(code: int = None) -> NoReturn: ...
@overload
def filter(function: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ...
@overload

View File

@@ -11,6 +11,7 @@ from typing import (
Optional, Generic, Set, Callable
)
from . import path
from mypy_extensions import NoReturn
# ----- os variables -----
@@ -314,7 +315,7 @@ def execve(path: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]], env: Mapping[
def execvp(file: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]]) -> None: ...
def execvpe(file: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]],
env: Mapping[str, str]) -> None: ...
def _exit(n: int) -> None: ...
def _exit(n: int) -> NoReturn: ...
def fork() -> int: ... # Unix only
def forkpty() -> Tuple[int, int]: ... # some flavors of Unix
def kill(pid: int, sig: int) -> None: ...

View File

@@ -8,6 +8,7 @@ from typing import (
TypeVar, Callable, Type,
)
from types import TracebackType
from mypy_extensions import NoReturn
_T = TypeVar('_T')
@@ -120,7 +121,7 @@ def exc_info() -> Tuple[Optional[Type[BaseException]],
Optional[BaseException],
Optional[TracebackType]]: ...
# sys.exit() accepts an optional argument of anything printable
def exit(arg: Any = ...) -> None:
def exit(arg: Any = ...) -> NoReturn:
raise SystemExit()
def getcheckinterval() -> int: ... # deprecated
def getdefaultencoding() -> str: ...