From 66e5863eadbbad207212310a512eca08a50f8470 Mon Sep 17 00:00:00 2001 From: rchen152 Date: Fri, 26 Jan 2018 14:28:37 -0800 Subject: [PATCH] Change the return type of unittest.TestCase.fail() to NoReturn (#1843) * Change the return type of unittest.TestCase.fail() to NoReturn * Import mypy_extensions.NoReturn instead of typing.NoReturn --- stdlib/2/unittest.pyi | 3 ++- stdlib/3/unittest/__init__.pyi | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/stdlib/2/unittest.pyi b/stdlib/2/unittest.pyi index bcd13e15d..e8b1b7f62 100644 --- a/stdlib/2/unittest.pyi +++ b/stdlib/2/unittest.pyi @@ -4,6 +4,7 @@ # Only a subset of functionality is included. +from mypy_extensions import NoReturn from typing import (Any, Callable, Dict, FrozenSet, Iterable, List, Optional, overload, Pattern, Sequence, Set, TextIO, Tuple, Type, TypeVar, Union) @@ -131,7 +132,7 @@ class TestCase(Testable): msg: object = ...) -> None: ... def assertNotIsInstance(self, obj: Any, cls: Union[type, Tuple[type, ...]], msg: object = ...) -> None: ... - def fail(self, msg: object = ...) -> None: ... + def fail(self, msg: object = ...) -> NoReturn: ... def countTestCases(self) -> int: ... def defaultTestResult(self) -> TestResult: ... def id(self) -> str: ... diff --git a/stdlib/3/unittest/__init__.pyi b/stdlib/3/unittest/__init__.pyi index 6c0e409d9..7bbbb0d40 100644 --- a/stdlib/3/unittest/__init__.pyi +++ b/stdlib/3/unittest/__init__.pyi @@ -1,9 +1,10 @@ # Stubs for unittest +from mypy_extensions import NoReturn from typing import ( - Any, Callable, Dict, Iterable, Iterator, List, Optional, Pattern, Sequence, - Set, FrozenSet, TextIO, Tuple, Type, TypeVar, Union, Generic, - overload, ContextManager + Any, Callable, ContextManager, Dict, FrozenSet, Generic, Iterable, Iterator, + List, Optional, overload, Pattern, Sequence, Set, TextIO, Tuple, Type, + TypeVar, Union ) import logging import sys @@ -134,7 +135,7 @@ class TestCase: second: Union[Set[Any], FrozenSet[Any]], msg: Any = ...) -> None: ... def assertDictEqual(self, first: Dict[Any, Any], second: Dict[Any, Any], msg: Any = ...) -> None: ... - def fail(self, msg: Any = ...) -> None: ... + def fail(self, msg: Any = ...) -> NoReturn: ... def countTestCases(self) -> int: ... def defaultTestResult(self) -> TestResult: ... def id(self) -> str: ...