Skip to content

Commit 97a74bc

Browse files
authored
Import from collections.abc wherever possible (#7635)
1 parent a17b3af commit 97a74bc

File tree

230 files changed

+445
-344
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+445
-344
lines changed

stdlib/_bisect.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
from _typeshed import SupportsRichComparisonT
3-
from typing import Callable, MutableSequence, Sequence, TypeVar, overload
3+
from collections.abc import Callable, MutableSequence, Sequence
4+
from typing import TypeVar, overload
45

56
_T = TypeVar("_T")
67

stdlib/_codecs.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import codecs
22
import sys
3-
from typing import Any, Callable
3+
from collections.abc import Callable
4+
from typing import Any
45
from typing_extensions import TypeAlias
56

67
# This type is not exposed; it is defined in unicodeobject.c

stdlib/_compression.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from _typeshed import WriteableBuffer
2+
from collections.abc import Callable
23
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
3-
from typing import Any, Callable, Protocol
4+
from typing import Any, Protocol
45

56
BUFFER_SIZE = DEFAULT_BUFFER_SIZE
67

stdlib/_csv.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Iterable, Iterator, Protocol, Union
1+
from collections.abc import Iterable, Iterator
2+
from typing import Any, Protocol, Union
23
from typing_extensions import Literal, TypeAlias
34

45
__version__: str

stdlib/_decimal.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import numbers
22
import sys
33
from _typeshed import Self
4+
from collections.abc import Container, Sequence
45
from types import TracebackType
5-
from typing import Any, Container, NamedTuple, Sequence, Union, overload
6+
from typing import Any, NamedTuple, Union, overload
67
from typing_extensions import TypeAlias
78

89
_Decimal: TypeAlias = Decimal | int

stdlib/_dummy_thread.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from collections.abc import Callable
12
from types import TracebackType
2-
from typing import Any, Callable, NoReturn
3+
from typing import Any, NoReturn
34

45
TIMEOUT_MAX: int
56
error = RuntimeError

stdlib/_dummy_threading.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
2+
from collections.abc import Callable, Iterable, Mapping
23
from types import FrameType, TracebackType
3-
from typing import Any, Callable, Iterable, Mapping, TypeVar
4+
from typing import Any, TypeVar
45
from typing_extensions import TypeAlias
56

67
# TODO recursive type

stdlib/_json.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Callable
1+
from collections.abc import Callable
2+
from typing import Any
23
from typing_extensions import final
34

45
@final

stdlib/_operator.pyi

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
import sys
2-
from typing import (
3-
Any,
4-
AnyStr,
5-
Callable,
6-
Container,
7-
Generic,
8-
Iterable,
9-
Mapping,
10-
MutableMapping,
11-
MutableSequence,
12-
Protocol,
13-
Sequence,
14-
SupportsAbs,
15-
TypeVar,
16-
overload,
17-
)
2+
from collections.abc import Callable, Container, Iterable, Mapping, MutableMapping, MutableSequence, Sequence
3+
from typing import Any, AnyStr, Generic, Protocol, SupportsAbs, TypeVar, overload
184
from typing_extensions import ParamSpec, SupportsIndex, TypeAlias, final
195

206
_R = TypeVar("_R")

stdlib/_osx_support.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
2-
from typing import Iterable, Sequence, TypeVar
2+
from collections.abc import Iterable, Sequence
3+
from typing import TypeVar
34

45
_T = TypeVar("_T")
56
_K = TypeVar("_K")

stdlib/_posixsubprocess.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from typing import Callable, Sequence
2+
from collections.abc import Callable, Sequence
33

44
if sys.platform != "win32":
55
def cloexec_pipe() -> tuple[int, int]: ...

stdlib/_sitebuiltins.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import ClassVar, Iterable, NoReturn
1+
from collections.abc import Iterable
2+
from typing import ClassVar, NoReturn
23
from typing_extensions import Literal
34

45
class Quitter:

stdlib/_thread.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import sys
22
from _typeshed import structseq
3+
from collections.abc import Callable
34
from threading import Thread
45
from types import TracebackType
5-
from typing import Any, Callable, NoReturn
6+
from typing import Any, NoReturn
67
from typing_extensions import Final, final
78

89
error = RuntimeError

stdlib/_tracemalloc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
2+
from collections.abc import Sequence
23
from tracemalloc import _FrameTupleT, _TraceTupleT
3-
from typing import Sequence
44

55
def _get_object_traceback(__obj: object) -> Sequence[_FrameTupleT] | None: ...
66
def _get_traces() -> Sequence[_TraceTupleT]: ...

stdlib/_typeshed/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import array
66
import ctypes
77
import mmap
88
import sys
9+
from collections.abc import Awaitable, Container, Iterable, Set as AbstractSet
910
from os import PathLike
1011
from types import TracebackType
11-
from typing import AbstractSet, Any, Awaitable, Container, Generic, Iterable, Protocol, TypeVar, Union
12+
from typing import Any, Generic, Protocol, TypeVar, Union
1213
from typing_extensions import Final, Literal, TypeAlias, final
1314

1415
_KT = TypeVar("_KT")

stdlib/_typeshed/wsgi.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import sys
88
from _typeshed import OptExcInfo
9-
from typing import Any, Callable, Iterable, Protocol
9+
from collections.abc import Callable, Iterable
10+
from typing import Any, Protocol
1011
from typing_extensions import TypeAlias
1112

1213
class _Readable(Protocol):

stdlib/_weakref.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
2-
from typing import Any, Callable, Generic, TypeVar, overload
2+
from collections.abc import Callable
3+
from typing import Any, Generic, TypeVar, overload
34
from typing_extensions import final
45

56
if sys.version_info >= (3, 9):

stdlib/_weakrefset.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
from _typeshed import Self
3-
from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar
3+
from collections.abc import Iterable, Iterator, MutableSet
4+
from typing import Any, Generic, TypeVar
45

56
if sys.version_info >= (3, 9):
67
from types import GenericAlias

stdlib/_winapi.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
2-
from typing import Any, NoReturn, Sequence, overload
2+
from collections.abc import Sequence
3+
from typing import Any, NoReturn, overload
34
from typing_extensions import Literal, final
45

56
if sys.platform == "win32":

stdlib/argparse.pyi

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
import sys
2-
from typing import (
3-
IO,
4-
Any,
5-
Callable,
6-
Generator,
7-
Generic,
8-
Iterable,
9-
NewType,
10-
NoReturn,
11-
Pattern,
12-
Protocol,
13-
Sequence,
14-
TypeVar,
15-
overload,
16-
)
2+
from collections.abc import Callable, Generator, Iterable, Sequence
3+
from typing import IO, Any, Generic, NewType, NoReturn, Pattern, Protocol, TypeVar, overload
174
from typing_extensions import Literal
185

196
if sys.version_info >= (3, 9):

stdlib/array.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
from _typeshed import Self
3-
from typing import Any, BinaryIO, Generic, Iterable, MutableSequence, TypeVar, overload
3+
from collections.abc import Iterable
4+
from typing import Any, BinaryIO, Generic, MutableSequence, TypeVar, overload
45
from typing_extensions import Literal, SupportsIndex, TypeAlias
56

67
_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]

stdlib/ast.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
from _ast import *
3-
from typing import Any, Iterator, TypeVar, overload
3+
from collections.abc import Iterator
4+
from typing import Any, TypeVar, overload
45
from typing_extensions import Literal
56

67
if sys.version_info >= (3, 8):

stdlib/asyncio/base_events.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ from asyncio.futures import Future
66
from asyncio.protocols import BaseProtocol
77
from asyncio.tasks import Task
88
from asyncio.transports import BaseTransport, ReadTransport, SubprocessTransport, WriteTransport
9-
from collections.abc import Iterable
9+
from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable, Sequence
1010
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
11-
from typing import IO, Any, Awaitable, Callable, Coroutine, Generator, Sequence, TypeVar, overload
11+
from typing import IO, Any, TypeVar, overload
1212
from typing_extensions import Literal, TypeAlias
1313

1414
if sys.version_info >= (3, 7):

stdlib/asyncio/base_futures.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
2-
from typing import Any, Callable, Sequence
2+
from collections.abc import Callable, Sequence
3+
from typing import Any
34
from typing_extensions import Literal
45

56
if sys.version_info >= (3, 7):

stdlib/asyncio/base_subprocess.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import subprocess
22
from collections import deque
3-
from typing import IO, Any, Callable, Sequence
3+
from collections.abc import Callable, Sequence
4+
from typing import IO, Any
45
from typing_extensions import TypeAlias
56

67
from . import events, futures, protocols, transports

stdlib/asyncio/events.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import ssl
22
import sys
33
from _typeshed import FileDescriptorLike, Self
44
from abc import ABCMeta, abstractmethod
5+
from collections.abc import Awaitable, Callable, Coroutine, Generator, Sequence
56
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
6-
from typing import IO, Any, Awaitable, Callable, Coroutine, Generator, Sequence, TypeVar, overload
7+
from typing import IO, Any, TypeVar, overload
78
from typing_extensions import Literal, TypeAlias
89

910
from .base_events import Server

stdlib/asyncio/format_helpers.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import functools
22
import traceback
3+
from collections.abc import Iterable
34
from types import FrameType, FunctionType
4-
from typing import Any, Iterable, overload
5+
from typing import Any, overload
56
from typing_extensions import TypeAlias
67

78
class _HasWrapper:

stdlib/asyncio/futures.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import sys
22
from _typeshed import Self
3+
from collections.abc import Awaitable, Callable, Generator, Iterable
34
from concurrent.futures._base import Error, Future as _ConcurrentFuture
4-
from typing import Any, Awaitable, Callable, Generator, Iterable, TypeVar
5+
from typing import Any, TypeVar
56
from typing_extensions import Literal, TypeGuard
67

78
from .events import AbstractEventLoop

stdlib/asyncio/locks.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import sys
22
from collections import deque
3+
from collections.abc import Callable, Generator
34
from types import TracebackType
4-
from typing import Any, Callable, Generator, TypeVar
5+
from typing import Any, TypeVar
56
from typing_extensions import Literal
67

78
from .events import AbstractEventLoop

stdlib/asyncio/proactor_events.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
2+
from collections.abc import Mapping
23
from socket import socket
3-
from typing import Any, Mapping, Protocol
4+
from typing import Any, Protocol
45
from typing_extensions import Literal
56

67
from . import base_events, constants, events, futures, streams, transports

stdlib/asyncio/runners.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
2-
from typing import Awaitable, TypeVar
2+
from collections.abc import Awaitable
3+
from typing import TypeVar
34

45
__all__ = ("run",)
56
_T = TypeVar("_T")

stdlib/asyncio/sslproto.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import ssl
22
import sys
33
from collections import deque
4-
from typing import Any, Callable, ClassVar
4+
from collections.abc import Callable
5+
from typing import Any, ClassVar
56
from typing_extensions import Literal
67

78
from . import constants, events, futures, protocols, transports

stdlib/asyncio/staggered.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Awaitable, Callable, Iterable
1+
from collections.abc import Awaitable, Callable, Iterable
2+
from typing import Any
23

34
from . import events
45

stdlib/asyncio/streams.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
from _typeshed import Self, StrPath
3-
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Sequence
3+
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Sequence
4+
from typing import Any
45
from typing_extensions import TypeAlias
56

67
from . import events, protocols, transports

stdlib/asyncio/subprocess.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import subprocess
22
import sys
33
from _typeshed import StrOrBytesPath
44
from asyncio import events, protocols, streams, transports
5-
from typing import IO, Any, Callable
5+
from collections.abc import Callable
6+
from typing import IO, Any
67
from typing_extensions import Literal, TypeAlias
78

89
if sys.version_info >= (3, 7):

stdlib/asyncio/taskgroups.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# This only exists in 3.11+. See VERSIONS.
22

33
from _typeshed import Self
4+
from collections.abc import Coroutine, Generator
45
from types import TracebackType
5-
from typing import Any, Coroutine, Generator, TypeVar
6+
from typing import Any, TypeVar
67

78
from .tasks import Task
89

stdlib/asyncio/tasks.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import concurrent.futures
22
import sys
3-
from collections.abc import Awaitable, Generator, Iterable, Iterator
3+
from collections.abc import Awaitable, Coroutine, Generator, Iterable, Iterator
44
from types import FrameType
5-
from typing import Any, Coroutine, Generic, TextIO, TypeVar, overload
5+
from typing import Any, Generic, TextIO, TypeVar, overload
66
from typing_extensions import Literal, TypeAlias
77

88
from .events import AbstractEventLoop

stdlib/asyncio/threads.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Callable, TypeVar
1+
from collections.abc import Callable
2+
from typing import TypeVar
23
from typing_extensions import ParamSpec
34

45
__all__ = ("to_thread",)

stdlib/asyncio/transports.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import sys
22
from asyncio.events import AbstractEventLoop
33
from asyncio.protocols import BaseProtocol
4+
from collections.abc import Mapping
45
from socket import _Address
5-
from typing import Any, Mapping
6+
from typing import Any
67

78
if sys.version_info >= (3, 7):
89
__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport")

stdlib/asyncio/trsock.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import socket
22
import sys
33
from builtins import type as Type # alias to avoid name clashes with property named "type"
4+
from collections.abc import Iterable
45
from types import TracebackType
5-
from typing import Any, BinaryIO, Iterable, NoReturn, overload
6+
from typing import Any, BinaryIO, NoReturn, overload
67
from typing_extensions import TypeAlias
78

89
# These are based in socket, maybe move them out into _typeshed.pyi or such

0 commit comments

Comments
 (0)