Import from collections.abc wherever possible (#7635)

This commit is contained in:
Alex Waygood
2022-04-18 11:50:37 +01:00
committed by GitHub
parent a17b3afb16
commit 97a74bc1aa
230 changed files with 449 additions and 348 deletions

View File

@@ -1,4 +1,4 @@
from typing import Awaitable, Callable
from collections.abc import Awaitable, Callable
from typing_extensions import ParamSpec
from .case import TestCase

View File

@@ -3,25 +3,10 @@ import logging
import sys
import unittest.result
from _typeshed import Self
from collections.abc import Set as AbstractSet
from collections.abc import Callable, Container, Iterable, Mapping, Sequence, Set as AbstractSet
from contextlib import AbstractContextManager
from types import TracebackType
from typing import (
Any,
AnyStr,
Callable,
ClassVar,
Container,
Generic,
Iterable,
Mapping,
NamedTuple,
NoReturn,
Pattern,
Sequence,
TypeVar,
overload,
)
from typing import Any, AnyStr, ClassVar, Generic, NamedTuple, NoReturn, Pattern, TypeVar, overload
from typing_extensions import ParamSpec
from warnings import WarningMessage

View File

@@ -2,8 +2,9 @@ import sys
import unittest.case
import unittest.result
import unittest.suite
from collections.abc import Callable, Sequence
from types import ModuleType
from typing import Any, Callable, Pattern, Sequence
from typing import Any, Pattern
from typing_extensions import TypeAlias
_SortComparisonMethod: TypeAlias = Callable[[str, str], int]

View File

@@ -3,8 +3,9 @@ import unittest.case
import unittest.loader
import unittest.result
import unittest.suite
from collections.abc import Iterable
from types import ModuleType
from typing import Any, Iterable, Protocol
from typing import Any, Protocol
MAIN_EXAMPLES: str
MODULE_EXAMPLES: str

View File

@@ -1,8 +1,9 @@
import sys
from _typeshed import Self
from collections.abc import Awaitable, Callable, Iterable, Mapping, Sequence
from contextlib import _GeneratorContextManager
from types import TracebackType
from typing import Any, Awaitable, Callable, Generic, Iterable, Mapping, Sequence, TypeVar, overload
from typing import Any, Generic, TypeVar, overload
from typing_extensions import Literal, TypeAlias
_T = TypeVar("_T")

View File

@@ -1,6 +1,7 @@
import unittest.case
from collections.abc import Callable
from types import TracebackType
from typing import Any, Callable, TextIO, TypeVar, Union
from typing import Any, TextIO, TypeVar, Union
from typing_extensions import TypeAlias
_SysExcInfoType: TypeAlias = Union[tuple[type[BaseException], BaseException, TracebackType], tuple[None, None, None]]

View File

@@ -1,7 +1,8 @@
import unittest.case
import unittest.result
import unittest.suite
from typing import Callable, Iterable, TextIO
from collections.abc import Callable, Iterable
from typing import TextIO
from typing_extensions import TypeAlias
_ResultClassType: TypeAlias = Callable[[TextIO, bool, int], unittest.result.TestResult]

View File

@@ -1,5 +1,6 @@
import unittest.result
from typing import Callable, TypeVar, overload
from collections.abc import Callable
from typing import TypeVar, overload
from typing_extensions import ParamSpec
_P = ParamSpec("_P")

View File

@@ -1,6 +1,6 @@
import unittest.case
import unittest.result
from typing import Iterable, Iterator
from collections.abc import Iterable, Iterator
from typing_extensions import TypeAlias
_TestType: TypeAlias = unittest.case.TestCase | TestSuite

View File

@@ -1,4 +1,5 @@
from typing import Any, Sequence, TypeVar
from collections.abc import Sequence
from typing import Any, TypeVar
from typing_extensions import TypeAlias
_T = TypeVar("_T")