mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-24 03:51:52 +08:00
Use TypeAlias where possible for type aliases (#7630)
This commit is contained in:
@@ -4,9 +4,10 @@ import unittest.result
|
||||
import unittest.suite
|
||||
from types import ModuleType
|
||||
from typing import Any, Callable, Pattern, Sequence
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_SortComparisonMethod = Callable[[str, str], int]
|
||||
_SuiteClass = Callable[[list[unittest.case.TestCase]], unittest.suite.TestSuite]
|
||||
_SortComparisonMethod: TypeAlias = Callable[[str, str], int]
|
||||
_SuiteClass: TypeAlias = Callable[[list[unittest.case.TestCase]], unittest.suite.TestSuite]
|
||||
|
||||
VALID_MODULE_NAME: Pattern[str]
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from _typeshed import Self
|
||||
from contextlib import _GeneratorContextManager
|
||||
from types import TracebackType
|
||||
from typing import Any, Awaitable, Callable, Generic, Iterable, Mapping, Sequence, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_TT = TypeVar("_TT", bound=type[Any])
|
||||
@@ -77,9 +77,9 @@ class _Sentinel:
|
||||
sentinel: Any
|
||||
DEFAULT: Any
|
||||
|
||||
_ArgsKwargs = tuple[tuple[Any, ...], Mapping[str, Any]]
|
||||
_NameArgsKwargs = tuple[str, tuple[Any, ...], Mapping[str, Any]]
|
||||
_CallValue = str | tuple[Any, ...] | Mapping[str, Any] | _ArgsKwargs | _NameArgsKwargs
|
||||
_ArgsKwargs: TypeAlias = tuple[tuple[Any, ...], Mapping[str, Any]]
|
||||
_NameArgsKwargs: TypeAlias = tuple[str, tuple[Any, ...], Mapping[str, Any]]
|
||||
_CallValue: TypeAlias = str | tuple[Any, ...] | Mapping[str, Any] | _ArgsKwargs | _NameArgsKwargs
|
||||
|
||||
class _Call(tuple[Any, ...]):
|
||||
def __new__(
|
||||
@@ -283,7 +283,7 @@ class _patch_dict:
|
||||
stop: Any
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
_Mock = MagicMock | AsyncMock
|
||||
_Mock: TypeAlias = MagicMock | AsyncMock
|
||||
else:
|
||||
_Mock = MagicMock
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import unittest.case
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, TextIO, TypeVar, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_SysExcInfoType = Union[tuple[type[BaseException], BaseException, TracebackType], tuple[None, None, None]]
|
||||
_SysExcInfoType: TypeAlias = Union[tuple[type[BaseException], BaseException, TracebackType], tuple[None, None, None]]
|
||||
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@ import unittest.case
|
||||
import unittest.result
|
||||
import unittest.suite
|
||||
from typing import Callable, Iterable, TextIO
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult]
|
||||
_ResultClassType: TypeAlias = Callable[[TextIO, bool, int], unittest.result.TestResult]
|
||||
|
||||
class TextTestResult(unittest.result.TestResult):
|
||||
descriptions: bool # undocumented
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import unittest.case
|
||||
import unittest.result
|
||||
from typing import Iterable, Iterator
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_TestType = unittest.case.TestCase | TestSuite
|
||||
_TestType: TypeAlias = unittest.case.TestCase | TestSuite
|
||||
|
||||
class BaseTestSuite(Iterable[_TestType]):
|
||||
_tests: list[unittest.case.TestCase]
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from typing import Any, Sequence, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_Mismatch = tuple[_T, _T, int]
|
||||
_Mismatch: TypeAlias = tuple[_T, _T, int]
|
||||
|
||||
_MAX_LENGTH: int
|
||||
_PLACEHOLDER_LEN: int
|
||||
|
||||
Reference in New Issue
Block a user