Use lowercase type everywhere (#6853)

This commit is contained in:
Alex Waygood
2022-01-08 15:09:29 +00:00
committed by GitHub
parent f8501d33c7
commit a40d79a4e6
172 changed files with 728 additions and 761 deletions

View File

@@ -1,7 +1,7 @@
import logging
import sys
from types import TracebackType
from typing import ClassVar, Generic, NamedTuple, Type, TypeVar
from typing import ClassVar, Generic, NamedTuple, TypeVar
from unittest.case import TestCase
_L = TypeVar("_L", None, _LoggingWatcher)
@@ -23,5 +23,5 @@ class _AssertLogsContext(Generic[_L]):
def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ...
def __enter__(self) -> _L: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...

View File

@@ -19,7 +19,6 @@ from typing import (
NoReturn,
Pattern,
Sequence,
Type,
TypeVar,
overload,
)
@@ -55,7 +54,7 @@ else:
def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ...
def __enter__(self) -> _LoggingWatcher: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
if sys.version_info >= (3, 8):
@@ -71,7 +70,7 @@ class SkipTest(Exception):
def __init__(self, reason: str) -> None: ...
class TestCase:
failureException: Type[BaseException]
failureException: type[BaseException]
longMessage: bool
maxDiff: int | None
# undocumented
@@ -110,17 +109,17 @@ class TestCase:
@overload
def assertRaises( # type: ignore[misc]
self,
expected_exception: Type[BaseException] | tuple[Type[BaseException], ...],
expected_exception: type[BaseException] | tuple[type[BaseException], ...],
callable: Callable[..., Any],
*args: Any,
**kwargs: Any,
) -> None: ...
@overload
def assertRaises(self, expected_exception: Type[_E] | tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ...
def assertRaises(self, expected_exception: type[_E] | tuple[type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ...
@overload
def assertRaisesRegex( # type: ignore[misc]
self,
expected_exception: Type[BaseException] | tuple[Type[BaseException], ...],
expected_exception: type[BaseException] | tuple[type[BaseException], ...],
expected_regex: str | bytes | Pattern[str] | Pattern[bytes],
callable: Callable[..., Any],
*args: Any,
@@ -129,20 +128,20 @@ class TestCase:
@overload
def assertRaisesRegex(
self,
expected_exception: Type[_E] | tuple[Type[_E], ...],
expected_exception: type[_E] | tuple[type[_E], ...],
expected_regex: str | bytes | Pattern[str] | Pattern[bytes],
msg: Any = ...,
) -> _AssertRaisesContext[_E]: ...
@overload
def assertWarns( # type: ignore[misc]
self, expected_warning: Type[Warning] | tuple[Type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any
self, expected_warning: type[Warning] | tuple[type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any
) -> None: ...
@overload
def assertWarns(self, expected_warning: Type[Warning] | tuple[Type[Warning], ...], msg: Any = ...) -> _AssertWarnsContext: ...
def assertWarns(self, expected_warning: type[Warning] | tuple[type[Warning], ...], msg: Any = ...) -> _AssertWarnsContext: ...
@overload
def assertWarnsRegex( # type: ignore[misc]
self,
expected_warning: Type[Warning] | tuple[Type[Warning], ...],
expected_warning: type[Warning] | tuple[type[Warning], ...],
expected_regex: str | bytes | Pattern[str] | Pattern[bytes],
callable: Callable[..., Any],
*args: Any,
@@ -151,7 +150,7 @@ class TestCase:
@overload
def assertWarnsRegex(
self,
expected_warning: Type[Warning] | tuple[Type[Warning], ...],
expected_warning: type[Warning] | tuple[type[Warning], ...],
expected_regex: str | bytes | Pattern[str] | Pattern[bytes],
msg: Any = ...,
) -> _AssertWarnsContext: ...
@@ -193,10 +192,10 @@ class TestCase:
def assertRegex(self, text: AnyStr, expected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ...
def assertNotRegex(self, text: AnyStr, unexpected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ...
def assertCountEqual(self, first: Iterable[Any], second: Iterable[Any], msg: Any = ...) -> None: ...
def addTypeEqualityFunc(self, typeobj: Type[Any], function: Callable[..., None]) -> None: ...
def addTypeEqualityFunc(self, typeobj: type[Any], function: Callable[..., None]) -> None: ...
def assertMultiLineEqual(self, first: str, second: str, msg: Any = ...) -> None: ...
def assertSequenceEqual(
self, seq1: Sequence[Any], seq2: Sequence[Any], msg: Any = ..., seq_type: Type[Sequence[Any]] | None = ...
self, seq1: Sequence[Any], seq2: Sequence[Any], msg: Any = ..., seq_type: type[Sequence[Any]] | None = ...
) -> None: ...
def assertListEqual(self, list1: list[Any], list2: list[Any], msg: Any = ...) -> None: ...
def assertTupleEqual(self, tuple1: tuple[Any, ...], tuple2: tuple[Any, ...], msg: Any = ...) -> None: ...
@@ -230,13 +229,13 @@ class TestCase:
@overload
def failUnlessRaises( # type: ignore[misc]
self,
exception: Type[BaseException] | tuple[Type[BaseException], ...],
exception: type[BaseException] | tuple[type[BaseException], ...],
callable: Callable[..., Any] = ...,
*args: Any,
**kwargs: Any,
) -> None: ...
@overload
def failUnlessRaises(self, exception: Type[_E] | tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ...
def failUnlessRaises(self, exception: type[_E] | tuple[type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ...
def failUnlessAlmostEqual(self, first: float, second: float, places: int = ..., msg: Any = ...) -> None: ...
def assertAlmostEquals(
self, first: float, second: float, places: int = ..., msg: Any = ..., delta: float = ...
@@ -250,7 +249,7 @@ class TestCase:
@overload
def assertRaisesRegexp( # type: ignore[misc]
self,
exception: Type[BaseException] | tuple[Type[BaseException], ...],
exception: type[BaseException] | tuple[type[BaseException], ...],
expected_regex: str | bytes | Pattern[str] | Pattern[bytes],
callable: Callable[..., Any],
*args: Any,
@@ -259,7 +258,7 @@ class TestCase:
@overload
def assertRaisesRegexp(
self,
exception: Type[_E] | tuple[Type[_E], ...],
exception: type[_E] | tuple[type[_E], ...],
expected_regex: str | bytes | Pattern[str] | Pattern[bytes],
msg: Any = ...,
) -> _AssertRaisesContext[_E]: ...
@@ -281,7 +280,7 @@ class _AssertRaisesContext(Generic[_E]):
exception: _E
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
@@ -293,5 +292,5 @@ class _AssertWarnsContext:
warnings: list[WarningMessage]
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...

View File

@@ -3,7 +3,7 @@ import unittest.case
import unittest.result
import unittest.suite
from types import ModuleType
from typing import Any, Callable, Pattern, Sequence, Type
from typing import Any, Callable, Pattern, Sequence
_SortComparisonMethod = Callable[[str, str], int]
_SuiteClass = Callable[[list[unittest.case.TestCase]], unittest.suite.TestSuite]
@@ -11,7 +11,7 @@ _SuiteClass = Callable[[list[unittest.case.TestCase]], unittest.suite.TestSuite]
VALID_MODULE_NAME: Pattern[str]
class TestLoader:
errors: list[Type[BaseException]]
errors: list[type[BaseException]]
testMethodPrefix: str
sortTestMethodsUsing: _SortComparisonMethod
@@ -19,18 +19,18 @@ class TestLoader:
testNamePatterns: list[str] | None
suiteClass: _SuiteClass
def loadTestsFromTestCase(self, testCaseClass: Type[unittest.case.TestCase]) -> unittest.suite.TestSuite: ...
def loadTestsFromTestCase(self, testCaseClass: type[unittest.case.TestCase]) -> unittest.suite.TestSuite: ...
def loadTestsFromModule(self, module: ModuleType, *args: Any, pattern: Any = ...) -> unittest.suite.TestSuite: ...
def loadTestsFromName(self, name: str, module: ModuleType | None = ...) -> unittest.suite.TestSuite: ...
def loadTestsFromNames(self, names: Sequence[str], module: ModuleType | None = ...) -> unittest.suite.TestSuite: ...
def getTestCaseNames(self, testCaseClass: Type[unittest.case.TestCase]) -> Sequence[str]: ...
def getTestCaseNames(self, testCaseClass: type[unittest.case.TestCase]) -> Sequence[str]: ...
def discover(self, start_dir: str, pattern: str = ..., top_level_dir: str | None = ...) -> unittest.suite.TestSuite: ...
defaultTestLoader: TestLoader
if sys.version_info >= (3, 7):
def getTestCaseNames(
testCaseClass: Type[unittest.case.TestCase],
testCaseClass: type[unittest.case.TestCase],
prefix: str,
sortUsing: _SortComparisonMethod = ...,
testNamePatterns: list[str] | None = ...,
@@ -38,11 +38,11 @@ if sys.version_info >= (3, 7):
else:
def getTestCaseNames(
testCaseClass: Type[unittest.case.TestCase], prefix: str, sortUsing: _SortComparisonMethod = ...
testCaseClass: type[unittest.case.TestCase], prefix: str, sortUsing: _SortComparisonMethod = ...
) -> Sequence[str]: ...
def makeSuite(
testCaseClass: Type[unittest.case.TestCase],
testCaseClass: type[unittest.case.TestCase],
prefix: str = ...,
sortUsing: _SortComparisonMethod = ...,
suiteClass: _SuiteClass = ...,

View File

@@ -4,7 +4,7 @@ import unittest.loader
import unittest.result
import unittest.suite
from types import ModuleType
from typing import Any, Iterable, Protocol, Type
from typing import Any, Iterable, Protocol
MAIN_EXAMPLES: str
MODULE_EXAMPLES: str
@@ -30,7 +30,7 @@ class TestProgram:
module: None | str | ModuleType = ...,
defaultTest: str | Iterable[str] | None = ...,
argv: list[str] | None = ...,
testRunner: Type[_TestRunner] | _TestRunner | None = ...,
testRunner: type[_TestRunner] | _TestRunner | None = ...,
testLoader: unittest.loader.TestLoader = ...,
exit: bool = ...,
verbosity: int = ...,

View File

@@ -1,8 +1,8 @@
import sys
from typing import Any, Awaitable, Callable, Generic, Iterable, Mapping, Sequence, Type, TypeVar, overload
from typing import Any, Awaitable, Callable, Generic, Iterable, Mapping, Sequence, TypeVar, overload
_T = TypeVar("_T")
_TT = TypeVar("_TT", bound=Type[Any])
_TT = TypeVar("_TT", bound=type[Any])
_R = TypeVar("_R")
if sys.version_info >= (3, 8):
@@ -106,10 +106,10 @@ class NonCallableMock(Base, Any):
def __new__(__cls, *args: Any, **kw: Any) -> NonCallableMock: ...
def __init__(
self,
spec: list[str] | object | Type[object] | None = ...,
spec: list[str] | object | type[object] | None = ...,
wraps: Any | None = ...,
name: str | None = ...,
spec_set: list[str] | object | Type[object] | None = ...,
spec_set: list[str] | object | type[object] | None = ...,
parent: NonCallableMock | None = ...,
_spec_state: Any | None = ...,
_new_name: str = ...,
@@ -258,7 +258,7 @@ class _patch_dict:
class _patcher:
TEST_PREFIX: str
dict: Type[_patch_dict]
dict: type[_patch_dict]
if sys.version_info >= (3, 8):
# This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any].
# Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],

View File

@@ -1,8 +1,8 @@
import unittest.case
from types import TracebackType
from typing import Any, Callable, TextIO, Type, TypeVar, Union
from typing import Any, Callable, TextIO, TypeVar, Union
_SysExcInfoType = Union[tuple[Type[BaseException], BaseException, TracebackType], tuple[None, None, None]]
_SysExcInfoType = Union[tuple[type[BaseException], BaseException, TracebackType], tuple[None, None, None]]
_F = TypeVar("_F", bound=Callable[..., Any])

View File

@@ -1,7 +1,7 @@
import unittest.case
import unittest.result
import unittest.suite
from typing import Callable, TextIO, Type
from typing import Callable, TextIO
_ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult]
@@ -27,7 +27,7 @@ class TextTestRunner:
failfast: bool = ...,
buffer: bool = ...,
resultclass: _ResultClassType | None = ...,
warnings: Type[Warning] | None = ...,
warnings: type[Warning] | None = ...,
*,
tb_locals: bool = ...,
) -> None: ...