From 708fd960dac5391ef4d8561d02158b5731ab3089 Mon Sep 17 00:00:00 2001 From: Danny Weinberg Date: Fri, 2 Sep 2016 19:04:56 -0700 Subject: [PATCH] Fix errors in stubs when running in strict mode (#515) --- stdlib/3/tempfile.pyi | 9 ++++++--- stdlib/3/unittest.pyi | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/stdlib/3/tempfile.pyi b/stdlib/3/tempfile.pyi index ce73d8aa0..4398b412b 100644 --- a/stdlib/3/tempfile.pyi +++ b/stdlib/3/tempfile.pyi @@ -3,7 +3,8 @@ # based on http://docs.python.org/3.3/library/tempfile.html -from typing import Tuple, BinaryIO +from types import TracebackType +from typing import BinaryIO, Optional, Tuple, Type # global variables tempdir = ... # type: str @@ -20,7 +21,7 @@ def TemporaryFile( def NamedTemporaryFile( mode: str = ..., buffering: int = ..., encoding: str = ..., newline: str = ..., suffix: str = ..., prefix: str = ..., - dir: str = ..., delete=...) -> BinaryIO: + dir: str = ..., delete: bool =...) -> BinaryIO: ... def SpooledTemporaryFile( max_size: int = ..., mode: str = ..., buffering: int = ..., @@ -34,7 +35,9 @@ class TemporaryDirectory: dir: str = ...) -> None: ... def cleanup(self) -> None: ... def __enter__(self) -> str: ... - def __exit__(self, type, value, traceback) -> bool: ... + def __exit__(self, exc_type: Optional[Type[BaseException]], + exc_val: Optional[Exception], + exc_tb: Optional[TracebackType]) -> bool: ... def mkstemp(suffix: str = ..., prefix: str = ..., dir: str = ..., text: bool = ...) -> Tuple[int, str]: ... diff --git a/stdlib/3/unittest.pyi b/stdlib/3/unittest.pyi index a727709e7..933e8f15e 100644 --- a/stdlib/3/unittest.pyi +++ b/stdlib/3/unittest.pyi @@ -8,6 +8,7 @@ from typing import ( import logging import sys from types import ModuleType, TracebackType +from contextlib import ContextManager _T = TypeVar('_T') @@ -37,7 +38,7 @@ class TestCase: def run(self, result: Optional[TestResult] = ...) -> TestCase: ... def skipTest(self, reason: Any) -> None: ... if sys.version_info >= (3, 4): - def subTest(self, msg: Any = ..., **params: Any) -> None: ... + def subTest(self, msg: Any = ..., **params: Any) -> ContextManager[None]: ... def debug(self) -> None: ... def assertEqual(self, first: Any, second: Any, msg: Any = ...) -> None: ... def assertNotEqual(self, first: Any, second: Any,