Skip to content

Use PEP 585 syntax everywhere #6688

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

Closed
wants to merge 8 commits into from
Closed
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
The table of contents is too big for display.
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 SupportsRichComparison
from typing import Callable, MutableSequence, Sequence, TypeVar
from collections.abc import Callable, MutableSequence, Sequence
from typing import TypeVar

_T = TypeVar("_T")

Expand Down
7 changes: 4 additions & 3 deletions stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import codecs
import sys
from typing import Any, Callable, Dict, Tuple, Union
from collections.abc import Callable
from typing import Any, Union

# This type is not exposed; it is defined in unicodeobject.c
class _EncodingMap:
def size(self) -> int: ...

_MapT = Union[Dict[int, int], _EncodingMap]
_Handler = Callable[[Exception], Tuple[str, int]]
_MapT = Union[dict[int, int], _EncodingMap]
_Handler = Callable[[Exception], tuple[str, int]]

def register(__search_function: Callable[[str], Any]) -> None: ...
def register_error(__errors: str, __handler: _Handler) -> None: ...
Expand Down
5 changes: 3 additions & 2 deletions 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 BufferedIOBase, RawIOBase
from typing import Any, Callable, Protocol, Tuple, Type
from typing import Any, Protocol, Type

BUFFER_SIZE: Any

Expand All @@ -16,7 +17,7 @@ class DecompressReader(RawIOBase):
self,
fp: _Reader,
decomp_factory: Callable[..., object],
trailing_error: Type[Exception] | Tuple[Type[Exception], ...] = ...,
trailing_error: Type[Exception] | tuple[Type[Exception], ...] = ...,
**decomp_args: Any,
) -> None: ...
def readable(self) -> bool: ...
Expand Down
5 changes: 3 additions & 2 deletions stdlib/_csv.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Iterable, Iterator, List, Protocol, Type, Union
from collections.abc import Iterable, Iterator
from typing import Any, Protocol, Type, Union

QUOTE_ALL: int
QUOTE_MINIMAL: int
Expand All @@ -20,7 +21,7 @@ class Dialect:

_DialectLike = Union[str, Dialect, Type[Dialect]]

class _reader(Iterator[List[str]]):
class _reader(Iterator[list[str]]):
dialect: Dialect
line_num: int
def __next__(self) -> list[str]: ...
Expand Down
5 changes: 3 additions & 2 deletions stdlib/_dummy_thread.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import Any, Callable, NoReturn, Tuple
from collections.abc import Callable
from typing import Any, NoReturn

TIMEOUT_MAX: int
error = RuntimeError

def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ...
def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ...
def exit() -> NoReturn: ...
def get_ident() -> int: ...
def allocate_lock() -> LockType: ...
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, Optional, Type, TypeVar
from typing import Any, Optional, Type, TypeVar

# TODO recursive type
_TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]]
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

class make_encoder:
sort_keys: Any
Expand Down
23 changes: 4 additions & 19 deletions stdlib/_operator.pyi
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
import sys
from _typeshed import SupportsAnyComparison
from typing import (
Any,
AnyStr,
Callable,
Container,
Generic,
Iterable,
Mapping,
MutableMapping,
MutableSequence,
Protocol,
Sequence,
SupportsAbs,
Tuple,
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, final

_R = TypeVar("_R")
Expand Down Expand Up @@ -99,7 +84,7 @@ class attrgetter(Generic[_T_co]):
@overload
def __new__(cls, attr: str, __attr2: str, __attr3: str, __attr4: str) -> attrgetter[tuple[Any, Any, Any, Any]]: ...
@overload
def __new__(cls, attr: str, *attrs: str) -> attrgetter[Tuple[Any, ...]]: ...
def __new__(cls, attr: str, *attrs: str) -> attrgetter[tuple[Any, ...]]: ...
def __call__(self, obj: Any) -> _T_co: ...

@final
Expand All @@ -113,7 +98,7 @@ class itemgetter(Generic[_T_co]):
@overload
def __new__(cls, item: Any, __item2: Any, __item3: Any, __item4: Any) -> itemgetter[tuple[Any, Any, Any, Any]]: ...
@overload
def __new__(cls, item: Any, *items: Any) -> itemgetter[Tuple[Any, ...]]: ...
def __new__(cls, item: Any, *items: Any) -> itemgetter[tuple[Any, ...]]: ...
def __call__(self, obj: Any) -> _T_co: ...

@final
Expand Down
7 changes: 4 additions & 3 deletions stdlib/_osx_support.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import sys
from typing import Iterable, Sequence, Tuple, TypeVar
from collections.abc import Iterable, Sequence
from typing import TypeVar

_T = TypeVar("_T")
_K = TypeVar("_K")
_V = TypeVar("_V")

__all__: list[str]

_UNIVERSAL_CONFIG_VARS: Tuple[str, ...] # undocumented
_COMPILER_CONFIG_VARS: Tuple[str, ...] # undocumented
_UNIVERSAL_CONFIG_VARS: tuple[str, ...] # undocumented
_COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented
_INITPRE: str # undocumented

def _find_executable(executable: str, path: str | None = ...) -> str | None: ... # undocumented
Expand Down
2 changes: 1 addition & 1 deletion stdlib/_posixsubprocess.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NOTE: These are incomplete!

from typing import Callable, Sequence
from collections.abc import Callable, Sequence

def cloexec_pipe() -> tuple[int, int]: ...
def fork_exec(
Expand Down
4 changes: 2 additions & 2 deletions stdlib/_py_abc.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Any, Tuple, Type, TypeVar
from typing import Any, Type, TypeVar

_T = TypeVar("_T")

# TODO: Change the return into a NewType bound to int after pytype/#597
def get_cache_token() -> object: ...

class ABCMeta(type):
def __new__(__mcls, __name: str, __bases: Tuple[Type[Any], ...], __namespace: dict[str, Any]) -> ABCMeta: ...
def __new__(__mcls, __name: str, __bases: tuple[Type[Any], ...], __namespace: dict[str, Any]) -> ABCMeta: ...
def register(cls, subclass: Type[_T]) -> Type[_T]: ...
4 changes: 1 addition & 3 deletions stdlib/_random.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import Tuple

# Actually Tuple[(int,) * 625]
_State = Tuple[int, ...]
_State = tuple[int, ...]

class Random(object):
def __init__(self, seed: object = ...) -> None: ...
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
8 changes: 4 additions & 4 deletions stdlib/_socket.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from collections.abc import Iterable
from typing import Any, SupportsInt, Tuple, Union, overload
from typing import Any, SupportsInt, Union, overload

if sys.version_info >= (3, 8):
from typing import SupportsIndex
Expand All @@ -10,12 +10,12 @@ if sys.version_info >= (3, 8):
else:
_FD = SupportsInt

_CMSG = Tuple[int, int, bytes]
_CMSGArg = Tuple[int, int, ReadableBuffer]
_CMSG = tuple[int, int, bytes]
_CMSGArg = tuple[int, int, ReadableBuffer]

# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6,
# AF_NETLINK, AF_TIPC) or strings (AF_UNIX).
_Address = Union[Tuple[Any, ...], str]
_Address = Union[tuple[Any, ...], str]
_RetAddress = Any
# TODO Most methods allow bytes as address objects

Expand Down
7 changes: 4 additions & 3 deletions 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, Optional, Tuple, Type
from typing import Any, NoReturn, Optional, Type
from typing_extensions import final

error = RuntimeError
Expand All @@ -21,7 +22,7 @@ class LockType:
self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...

def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ...
def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ...
def interrupt_main() -> None: ...
def exit() -> NoReturn: ...
def allocate_lock() -> LockType: ...
Expand All @@ -34,7 +35,7 @@ if sys.version_info >= (3, 8):
def get_native_id() -> int: ... # only available on some platforms
@final
class _ExceptHookArgs(
structseq[Any], Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]
structseq[Any], tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]
):
@property
def exc_type(self) -> Type[BaseException]: ...
Expand Down
4 changes: 2 additions & 2 deletions stdlib/_threading_local.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Dict
from typing import Any
from weakref import ReferenceType

localdict = Dict[Any, Any]
localdict = dict[Any, Any]

class _localimpl:
key: str
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,8 +6,9 @@ import array
import ctypes
import mmap
import sys
from collections.abc import Awaitable, Container, Iterable, Set as AbstractSet
from os import PathLike
from typing import AbstractSet, Any, Awaitable, ClassVar, Container, Generic, Iterable, Protocol, Type, TypeVar, Union
from typing import Any, ClassVar, Generic, Protocol, Type, TypeVar, Union
from typing_extensions import Literal, final

_KT = TypeVar("_KT")
Expand Down
5 changes: 3 additions & 2 deletions stdlib/_typeshed/wsgi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
#
# See the README.md file in this directory for more information.

from collections.abc import Callable, Iterable
from sys import _OptExcInfo
from typing import Any, Callable, Dict, Iterable, Protocol
from typing import Any, Protocol

# stable
class StartResponse(Protocol):
def __call__(
self, status: str, headers: list[tuple[str, str]], exc_info: _OptExcInfo | None = ...
) -> Callable[[bytes], Any]: ...

WSGIEnvironment = Dict[str, Any] # stable
WSGIEnvironment = dict[str, Any] # stable
WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]] # stable

# WSGI input streams per PEP 3333, stable
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,5 +1,6 @@
import sys
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

CREATE_NEW_CONSOLE: int
Expand Down
5 changes: 3 additions & 2 deletions stdlib/abc.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import sys
from _typeshed import SupportsWrite
from typing import Any, Callable, Tuple, Type, TypeVar
from collections.abc import Callable
from typing import Any, Type, TypeVar

_T = TypeVar("_T")
_FuncT = TypeVar("_FuncT", bound=Callable[..., Any])

# These definitions have special processing in mypy
class ABCMeta(type):
__abstractmethods__: frozenset[str]
def __init__(self, name: str, bases: Tuple[type, ...], namespace: dict[str, Any]) -> None: ...
def __init__(self, name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> None: ...
def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ...
def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ...
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = ...) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions stdlib/aifc.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from _typeshed import Self
from types import TracebackType
from typing import IO, Any, NamedTuple, Tuple, Type, Union, overload
from typing import IO, Any, NamedTuple, Type, Union, overload
from typing_extensions import Literal

class Error(Exception): ...
Expand All @@ -15,7 +15,7 @@ class _aifc_params(NamedTuple):
compname: bytes

_File = Union[str, IO[bytes]]
_Marker = Tuple[int, int, bytes]
_Marker = tuple[int, int, bytes]

class Aifc_read:
def __init__(self, f: _File) -> None: ...
Expand Down
Loading