Skip to content

Import from collections.abc wherever possible #7635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stdlib/_bisect.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from _typeshed import SupportsRichComparisonT
from typing import Callable, MutableSequence, Sequence, TypeVar, overload
from collections.abc import Callable, MutableSequence, Sequence
from typing import TypeVar, overload

_T = TypeVar("_T")

Expand Down
3 changes: 2 additions & 1 deletion stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import codecs
import sys
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
from typing_extensions import TypeAlias

# This type is not exposed; it is defined in unicodeobject.c
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_compression.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from _typeshed import WriteableBuffer
from collections.abc import Callable
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
from typing import Any, Callable, Protocol
from typing import Any, Protocol

BUFFER_SIZE = DEFAULT_BUFFER_SIZE

Expand Down
3 changes: 2 additions & 1 deletion stdlib/_csv.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Iterable, Iterator, Protocol, Union
from collections.abc import Iterable, Iterator
from typing import Any, Protocol, Union
from typing_extensions import Literal, TypeAlias

__version__: str
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_decimal.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import numbers
import sys
from _typeshed import Self
from collections.abc import Container, Sequence
from types import TracebackType
from typing import Any, Container, NamedTuple, Sequence, Union, overload
from typing import Any, NamedTuple, Union, overload
from typing_extensions import TypeAlias

_Decimal: TypeAlias = Decimal | int
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_dummy_thread.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Callable
from types import TracebackType
from typing import Any, Callable, NoReturn
from typing import Any, NoReturn

TIMEOUT_MAX: int
error = RuntimeError
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_dummy_threading.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from collections.abc import Callable, Iterable, Mapping
from types import FrameType, TracebackType
from typing import Any, Callable, Iterable, Mapping, TypeVar
from typing import Any, TypeVar
from typing_extensions import TypeAlias

# TODO recursive type
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_json.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
from typing_extensions import final

@final
Expand Down
18 changes: 2 additions & 16 deletions stdlib/_operator.pyi
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
import sys
from typing import (
Any,
AnyStr,
Callable,
Container,
Generic,
Iterable,
Mapping,
MutableMapping,
MutableSequence,
Protocol,
Sequence,
SupportsAbs,
TypeVar,
overload,
)
from collections.abc import Callable, Container, Iterable, Mapping, MutableMapping, MutableSequence, Sequence
from typing import Any, AnyStr, Generic, Protocol, SupportsAbs, TypeVar, overload
from typing_extensions import ParamSpec, SupportsIndex, TypeAlias, final

_R = TypeVar("_R")
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_osx_support.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from typing import Iterable, Sequence, TypeVar
from collections.abc import Iterable, Sequence
from typing import TypeVar

_T = TypeVar("_T")
_K = TypeVar("_K")
Expand Down
2 changes: 1 addition & 1 deletion stdlib/_posixsubprocess.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import Callable, Sequence
from collections.abc import Callable, Sequence

if sys.platform != "win32":
def cloexec_pipe() -> tuple[int, int]: ...
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_sitebuiltins.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import ClassVar, Iterable, NoReturn
from collections.abc import Iterable
from typing import ClassVar, NoReturn
from typing_extensions import Literal

class Quitter:
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_thread.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import sys
from _typeshed import structseq
from collections.abc import Callable
from threading import Thread
from types import TracebackType
from typing import Any, Callable, NoReturn
from typing import Any, NoReturn
from typing_extensions import Final, final

error = RuntimeError
Expand Down
2 changes: 1 addition & 1 deletion stdlib/_tracemalloc.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from collections.abc import Sequence
from tracemalloc import _FrameTupleT, _TraceTupleT
from typing import Sequence

def _get_object_traceback(__obj: object) -> Sequence[_FrameTupleT] | None: ...
def _get_traces() -> Sequence[_TraceTupleT]: ...
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import array
import ctypes
import mmap
import sys
from collections.abc import Awaitable, Container, Iterable, Set as AbstractSet
from os import PathLike
from types import TracebackType
from typing import AbstractSet, Any, Awaitable, Container, Generic, Iterable, Protocol, TypeVar, Union
from typing import Any, Generic, Protocol, TypeVar, Union
from typing_extensions import Final, Literal, TypeAlias, final

_KT = TypeVar("_KT")
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_typeshed/wsgi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import sys
from _typeshed import OptExcInfo
from typing import Any, Callable, Iterable, Protocol
from collections.abc import Callable, Iterable
from typing import Any, Protocol
from typing_extensions import TypeAlias

class _Readable(Protocol):
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_weakref.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from typing import Any, Callable, Generic, TypeVar, overload
from collections.abc import Callable
from typing import Any, Generic, TypeVar, overload
from typing_extensions import final

if sys.version_info >= (3, 9):
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_weakrefset.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from _typeshed import Self
from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar
from collections.abc import Iterable, Iterator, MutableSet
from typing import Any, Generic, TypeVar

if sys.version_info >= (3, 9):
from types import GenericAlias
Expand Down
3 changes: 2 additions & 1 deletion stdlib/_winapi.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from typing import Any, NoReturn, Sequence, overload
from collections.abc import Sequence
from typing import Any, NoReturn, overload
from typing_extensions import Literal, final

if sys.platform == "win32":
Expand Down
17 changes: 2 additions & 15 deletions stdlib/argparse.pyi
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import sys
from typing import (
IO,
Any,
Callable,
Generator,
Generic,
Iterable,
NewType,
NoReturn,
Pattern,
Protocol,
Sequence,
TypeVar,
overload,
)
from collections.abc import Callable, Generator, Iterable, Sequence
from typing import IO, Any, Generic, NewType, NoReturn, Pattern, Protocol, TypeVar, overload
from typing_extensions import Literal

if sys.version_info >= (3, 9):
Expand Down
3 changes: 2 additions & 1 deletion stdlib/array.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from _typeshed import Self
from typing import Any, BinaryIO, Generic, Iterable, MutableSequence, TypeVar, overload
from collections.abc import Iterable
from typing import Any, BinaryIO, Generic, MutableSequence, TypeVar, overload
from typing_extensions import Literal, SupportsIndex, TypeAlias

_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
Expand Down
3 changes: 2 additions & 1 deletion stdlib/ast.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from _ast import *
from typing import Any, Iterator, TypeVar, overload
from collections.abc import Iterator
from typing import Any, TypeVar, overload
from typing_extensions import Literal

if sys.version_info >= (3, 8):
Expand Down
4 changes: 2 additions & 2 deletions stdlib/asyncio/base_events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ from asyncio.futures import Future
from asyncio.protocols import BaseProtocol
from asyncio.tasks import Task
from asyncio.transports import BaseTransport, ReadTransport, SubprocessTransport, WriteTransport
from collections.abc import Iterable
from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable, Sequence
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
from typing import IO, Any, Awaitable, Callable, Coroutine, Generator, Sequence, TypeVar, overload
from typing import IO, Any, TypeVar, overload
from typing_extensions import Literal, TypeAlias

if sys.version_info >= (3, 7):
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/base_futures.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from typing import Any, Callable, Sequence
from collections.abc import Callable, Sequence
from typing import Any
from typing_extensions import Literal

if sys.version_info >= (3, 7):
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/base_subprocess.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess
from collections import deque
from typing import IO, Any, Callable, Sequence
from collections.abc import Callable, Sequence
from typing import IO, Any
from typing_extensions import TypeAlias

from . import events, futures, protocols, transports
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import ssl
import sys
from _typeshed import FileDescriptorLike, Self
from abc import ABCMeta, abstractmethod
from collections.abc import Awaitable, Callable, Coroutine, Generator, Sequence
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
from typing import IO, Any, Awaitable, Callable, Coroutine, Generator, Sequence, TypeVar, overload
from typing import IO, Any, TypeVar, overload
from typing_extensions import Literal, TypeAlias

from .base_events import Server
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/format_helpers.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import functools
import traceback
from collections.abc import Iterable
from types import FrameType, FunctionType
from typing import Any, Iterable, overload
from typing import Any, overload
from typing_extensions import TypeAlias

class _HasWrapper:
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/futures.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
from _typeshed import Self
from collections.abc import Awaitable, Callable, Generator, Iterable
from concurrent.futures._base import Error, Future as _ConcurrentFuture
from typing import Any, Awaitable, Callable, Generator, Iterable, TypeVar
from typing import Any, TypeVar
from typing_extensions import Literal, TypeGuard

from .events import AbstractEventLoop
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/locks.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
from collections import deque
from collections.abc import Callable, Generator
from types import TracebackType
from typing import Any, Callable, Generator, TypeVar
from typing import Any, TypeVar
from typing_extensions import Literal

from .events import AbstractEventLoop
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/proactor_events.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from collections.abc import Mapping
from socket import socket
from typing import Any, Mapping, Protocol
from typing import Any, Protocol
from typing_extensions import Literal

from . import base_events, constants, events, futures, streams, transports
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/runners.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from typing import Awaitable, TypeVar
from collections.abc import Awaitable
from typing import TypeVar

__all__ = ("run",)
_T = TypeVar("_T")
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/sslproto.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ssl
import sys
from collections import deque
from typing import Any, Callable, ClassVar
from collections.abc import Callable
from typing import Any, ClassVar
from typing_extensions import Literal

from . import constants, events, futures, protocols, transports
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/staggered.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Awaitable, Callable, Iterable
from collections.abc import Awaitable, Callable, Iterable
from typing import Any

from . import events

Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/streams.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from _typeshed import Self, StrPath
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Sequence
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Sequence
from typing import Any
from typing_extensions import TypeAlias

from . import events, protocols, transports
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/subprocess.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import subprocess
import sys
from _typeshed import StrOrBytesPath
from asyncio import events, protocols, streams, transports
from typing import IO, Any, Callable
from collections.abc import Callable
from typing import IO, Any
from typing_extensions import Literal, TypeAlias

if sys.version_info >= (3, 7):
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/taskgroups.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# This only exists in 3.11+. See VERSIONS.

from _typeshed import Self
from collections.abc import Coroutine, Generator
from types import TracebackType
from typing import Any, Coroutine, Generator, TypeVar
from typing import Any, TypeVar

from .tasks import Task

Expand Down
4 changes: 2 additions & 2 deletions stdlib/asyncio/tasks.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import concurrent.futures
import sys
from collections.abc import Awaitable, Generator, Iterable, Iterator
from collections.abc import Awaitable, Coroutine, Generator, Iterable, Iterator
from types import FrameType
from typing import Any, Coroutine, Generic, TextIO, TypeVar, overload
from typing import Any, Generic, TextIO, TypeVar, overload
from typing_extensions import Literal, TypeAlias

from .events import AbstractEventLoop
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/threads.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Callable, TypeVar
from collections.abc import Callable
from typing import TypeVar
from typing_extensions import ParamSpec

__all__ = ("to_thread",)
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/transports.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import sys
from asyncio.events import AbstractEventLoop
from asyncio.protocols import BaseProtocol
from collections.abc import Mapping
from socket import _Address
from typing import Any, Mapping
from typing import Any

if sys.version_info >= (3, 7):
__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport")
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/trsock.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import socket
import sys
from builtins import type as Type # alias to avoid name clashes with property named "type"
from collections.abc import Iterable
from types import TracebackType
from typing import Any, BinaryIO, Iterable, NoReturn, overload
from typing import Any, BinaryIO, NoReturn, overload
from typing_extensions import TypeAlias

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