Skip to content

Commit 8d5d252

Browse files
authored
Use PEP 585 syntax wherever possible (#6717)
1 parent e6cb341 commit 8d5d252

File tree

237 files changed

+967
-1070
lines changed

Some content is hidden

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

237 files changed

+967
-1070
lines changed

stdlib/_codecs.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import codecs
22
import sys
3-
from typing import Any, Callable, Dict, Tuple, Union
3+
from typing import Any, Callable, Union
44

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

9-
_MapT = Union[Dict[int, int], _EncodingMap]
10-
_Handler = Callable[[Exception], Tuple[str, int]]
9+
_MapT = Union[dict[int, int], _EncodingMap]
10+
_Handler = Callable[[Exception], tuple[str, int]]
1111

1212
def register(__search_function: Callable[[str], Any]) -> None: ...
1313
def register_error(__errors: str, __handler: _Handler) -> None: ...

stdlib/_compression.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import WriteableBuffer
22
from io import BufferedIOBase, RawIOBase
3-
from typing import Any, Callable, Protocol, Tuple, Type
3+
from typing import Any, Callable, Protocol, Type
44

55
BUFFER_SIZE: Any
66

@@ -16,7 +16,7 @@ class DecompressReader(RawIOBase):
1616
self,
1717
fp: _Reader,
1818
decomp_factory: Callable[..., object],
19-
trailing_error: Type[Exception] | Tuple[Type[Exception], ...] = ...,
19+
trailing_error: Type[Exception] | tuple[Type[Exception], ...] = ...,
2020
**decomp_args: Any,
2121
) -> None: ...
2222
def readable(self) -> bool: ...

stdlib/_csv.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Iterable, Iterator, List, Protocol, Type, Union
1+
from typing import Any, Iterable, Iterator, Protocol, Type, Union
22

33
QUOTE_ALL: int
44
QUOTE_MINIMAL: int
@@ -20,7 +20,7 @@ class Dialect:
2020

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

23-
class _reader(Iterator[List[str]]):
23+
class _reader(Iterator[list[str]]):
2424
dialect: Dialect
2525
line_num: int
2626
def __next__(self) -> list[str]: ...

stdlib/_dummy_thread.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from typing import Any, Callable, NoReturn, Tuple
1+
from typing import Any, Callable, NoReturn
22

33
TIMEOUT_MAX: int
44
error = RuntimeError
55

6-
def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ...
6+
def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ...
77
def exit() -> NoReturn: ...
88
def get_ident() -> int: ...
99
def allocate_lock() -> LockType: ...

stdlib/_operator.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ from typing import (
1313
Protocol,
1414
Sequence,
1515
SupportsAbs,
16-
Tuple,
1716
TypeVar,
1817
overload,
1918
)
@@ -99,7 +98,7 @@ class attrgetter(Generic[_T_co]):
9998
@overload
10099
def __new__(cls, attr: str, __attr2: str, __attr3: str, __attr4: str) -> attrgetter[tuple[Any, Any, Any, Any]]: ...
101100
@overload
102-
def __new__(cls, attr: str, *attrs: str) -> attrgetter[Tuple[Any, ...]]: ...
101+
def __new__(cls, attr: str, *attrs: str) -> attrgetter[tuple[Any, ...]]: ...
103102
def __call__(self, obj: Any) -> _T_co: ...
104103

105104
@final
@@ -113,7 +112,7 @@ class itemgetter(Generic[_T_co]):
113112
@overload
114113
def __new__(cls, item: Any, __item2: Any, __item3: Any, __item4: Any) -> itemgetter[tuple[Any, Any, Any, Any]]: ...
115114
@overload
116-
def __new__(cls, item: Any, *items: Any) -> itemgetter[Tuple[Any, ...]]: ...
115+
def __new__(cls, item: Any, *items: Any) -> itemgetter[tuple[Any, ...]]: ...
117116
def __call__(self, obj: Any) -> _T_co: ...
118117

119118
@final

stdlib/_osx_support.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import sys
2-
from typing import Iterable, Sequence, Tuple, TypeVar
2+
from typing import Iterable, Sequence, TypeVar
33

44
_T = TypeVar("_T")
55
_K = TypeVar("_K")
66
_V = TypeVar("_V")
77

88
__all__: list[str]
99

10-
_UNIVERSAL_CONFIG_VARS: Tuple[str, ...] # undocumented
11-
_COMPILER_CONFIG_VARS: Tuple[str, ...] # undocumented
10+
_UNIVERSAL_CONFIG_VARS: tuple[str, ...] # undocumented
11+
_COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented
1212
_INITPRE: str # undocumented
1313

1414
def _find_executable(executable: str, path: str | None = ...) -> str | None: ... # undocumented

stdlib/_py_abc.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from typing import Any, Tuple, Type, TypeVar
1+
from typing import Any, Type, TypeVar
22

33
_T = TypeVar("_T")
44

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

88
class ABCMeta(type):
9-
def __new__(__mcls, __name: str, __bases: Tuple[Type[Any], ...], __namespace: dict[str, Any]) -> ABCMeta: ...
9+
def __new__(__mcls, __name: str, __bases: tuple[Type[Any], ...], __namespace: dict[str, Any]) -> ABCMeta: ...
1010
def register(cls, subclass: Type[_T]) -> Type[_T]: ...

stdlib/_random.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from typing import Tuple
2-
31
# Actually Tuple[(int,) * 625]
4-
_State = Tuple[int, ...]
2+
_State = tuple[int, ...]
53

64
class Random(object):
75
def __init__(self, seed: object = ...) -> None: ...

stdlib/_socket.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from _typeshed import ReadableBuffer, WriteableBuffer
33
from collections.abc import Iterable
4-
from typing import Any, SupportsInt, Tuple, Union, overload
4+
from typing import Any, SupportsInt, Union, overload
55

66
if sys.version_info >= (3, 8):
77
from typing import SupportsIndex
@@ -10,12 +10,12 @@ if sys.version_info >= (3, 8):
1010
else:
1111
_FD = SupportsInt
1212

13-
_CMSG = Tuple[int, int, bytes]
14-
_CMSGArg = Tuple[int, int, ReadableBuffer]
13+
_CMSG = tuple[int, int, bytes]
14+
_CMSGArg = tuple[int, int, ReadableBuffer]
1515

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

stdlib/_thread.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
from _typeshed import structseq
33
from threading import Thread
44
from types import TracebackType
5-
from typing import Any, Callable, NoReturn, Optional, Tuple, Type
5+
from typing import Any, Callable, NoReturn, Optional, Type
66
from typing_extensions import final
77

88
error = RuntimeError
@@ -21,7 +21,7 @@ class LockType:
2121
self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
2222
) -> None: ...
2323

24-
def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ...
24+
def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ...
2525
def interrupt_main() -> None: ...
2626
def exit() -> NoReturn: ...
2727
def allocate_lock() -> LockType: ...
@@ -34,7 +34,7 @@ if sys.version_info >= (3, 8):
3434
def get_native_id() -> int: ... # only available on some platforms
3535
@final
3636
class _ExceptHookArgs(
37-
structseq[Any], Tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]
37+
structseq[Any], tuple[Type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]]
3838
):
3939
@property
4040
def exc_type(self) -> Type[BaseException]: ...

0 commit comments

Comments
 (0)