Skip to content

Commit a40d79a

Browse files
authored
Use lowercase type everywhere (#6853)
1 parent f8501d3 commit a40d79a

File tree

172 files changed

+728
-761
lines changed

Some content is hidden

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

172 files changed

+728
-761
lines changed

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, Type
3+
from typing import Any, Callable, Protocol
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, Protocol, Type, Union
1+
from typing import Any, Iterable, Iterator, Protocol, Union
22
from typing_extensions import Literal
33

44
QUOTE_ALL: Literal[1]
@@ -19,7 +19,7 @@ class Dialect:
1919
strict: int
2020
def __init__(self) -> None: ...
2121

22-
_DialectLike = Union[str, Dialect, Type[Dialect]]
22+
_DialectLike = Union[str, Dialect, type[Dialect]]
2323

2424
class _reader(Iterator[list[str]]):
2525
dialect: Dialect

stdlib/_dummy_threading.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from types import FrameType, TracebackType
3-
from typing import Any, Callable, Iterable, Mapping, Optional, Type, TypeVar
3+
from typing import Any, Callable, Iterable, Mapping, Optional, TypeVar
44

55
# TODO recursive type
66
_TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]]
@@ -67,7 +67,7 @@ class Lock:
6767
def __init__(self) -> None: ...
6868
def __enter__(self) -> bool: ...
6969
def __exit__(
70-
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
70+
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
7171
) -> bool | None: ...
7272
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
7373
def release(self) -> None: ...
@@ -77,7 +77,7 @@ class _RLock:
7777
def __init__(self) -> None: ...
7878
def __enter__(self) -> bool: ...
7979
def __exit__(
80-
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
80+
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
8181
) -> bool | None: ...
8282
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
8383
def release(self) -> None: ...
@@ -88,7 +88,7 @@ class Condition:
8888
def __init__(self, lock: Lock | _RLock | None = ...) -> None: ...
8989
def __enter__(self) -> bool: ...
9090
def __exit__(
91-
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
91+
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
9292
) -> bool | None: ...
9393
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
9494
def release(self) -> None: ...
@@ -101,7 +101,7 @@ class Condition:
101101
class Semaphore:
102102
def __init__(self, value: int = ...) -> None: ...
103103
def __exit__(
104-
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
104+
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
105105
) -> bool | None: ...
106106
def acquire(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ...
107107
def __enter__(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ...

stdlib/_py_abc.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from typing import Any, Type, TypeVar
1+
from typing import Any, 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: ...
10-
def register(cls, subclass: Type[_T]) -> Type[_T]: ...
9+
def __new__(__mcls, __name: str, __bases: tuple[type[Any], ...], __namespace: dict[str, Any]) -> ABCMeta: ...
10+
def register(cls, subclass: type[_T]) -> type[_T]: ...

stdlib/_thread.pyi

Lines changed: 4 additions & 4 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, Type
5+
from typing import Any, Callable, NoReturn, Optional
66
from typing_extensions import final
77

88
error = RuntimeError
@@ -18,7 +18,7 @@ class LockType:
1818
def locked(self) -> bool: ...
1919
def __enter__(self) -> bool: ...
2020
def __exit__(
21-
self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
21+
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
2222
) -> None: ...
2323

2424
def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ...
@@ -34,10 +34,10 @@ 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
40-
def exc_type(self) -> Type[BaseException]: ...
40+
def exc_type(self) -> type[BaseException]: ...
4141
@property
4242
def exc_value(self) -> BaseException | None: ...
4343
@property

stdlib/_typeshed/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ctypes
77
import mmap
88
import sys
99
from os import PathLike
10-
from typing import AbstractSet, Any, Awaitable, Container, Generic, Iterable, Protocol, Type, TypeVar, Union
10+
from typing import AbstractSet, Any, Awaitable, Container, Generic, Iterable, Protocol, TypeVar, Union
1111
from typing_extensions import Final, Literal, final
1212

1313
_KT = TypeVar("_KT")
@@ -215,4 +215,4 @@ class structseq(Generic[_T_co]):
215215
# The second parameter will accept a dict of any kind without raising an exception,
216216
# but only has any meaning if you supply it a dict where the keys are strings.
217217
# https://github.com/python/typeshed/pull/6560#discussion_r767149830
218-
def __new__(cls: Type[_T], sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> _T: ...
218+
def __new__(cls: type[_T], sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> _T: ...

stdlib/_warnings.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
from typing import Any, Type, overload
1+
from typing import Any, overload
22

33
_defaultaction: str
44
_onceregistry: dict[Any, Any]
5-
filters: list[tuple[str, str | None, Type[Warning], str | None, int]]
5+
filters: list[tuple[str, str | None, type[Warning], str | None, int]]
66

77
@overload
8-
def warn(message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ...
8+
def warn(message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ...
99
@overload
1010
def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ...
1111
@overload
1212
def warn_explicit(
1313
message: str,
14-
category: Type[Warning],
14+
category: type[Warning],
1515
filename: str,
1616
lineno: int,
1717
module: str | None = ...,
18-
registry: dict[str | tuple[str, Type[Warning], int], int] | None = ...,
18+
registry: dict[str | tuple[str, type[Warning], int], int] | None = ...,
1919
module_globals: dict[str, Any] | None = ...,
2020
source: Any | None = ...,
2121
) -> None: ...
@@ -26,7 +26,7 @@ def warn_explicit(
2626
filename: str,
2727
lineno: int,
2828
module: str | None = ...,
29-
registry: dict[str | tuple[str, Type[Warning], int], int] | None = ...,
29+
registry: dict[str | tuple[str, type[Warning], int], int] | None = ...,
3030
module_globals: dict[str, Any] | None = ...,
3131
source: Any | None = ...,
3232
) -> None: ...

stdlib/abc.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from _typeshed import SupportsWrite
3-
from typing import Any, Callable, Type, TypeVar
3+
from typing import Any, Callable, TypeVar
44

55
_T = TypeVar("_T")
66
_FuncT = TypeVar("_FuncT", bound=Callable[..., Any])
@@ -12,7 +12,7 @@ class ABCMeta(type):
1212
def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ...
1313
def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ...
1414
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = ...) -> None: ...
15-
def register(cls: ABCMeta, subclass: Type[_T]) -> Type[_T]: ...
15+
def register(cls: ABCMeta, subclass: type[_T]) -> type[_T]: ...
1616

1717
def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
1818

@@ -27,4 +27,4 @@ class ABC(metaclass=ABCMeta): ...
2727
def get_cache_token() -> object: ...
2828

2929
if sys.version_info >= (3, 10):
30-
def update_abstractmethods(cls: Type[_T]) -> Type[_T]: ...
30+
def update_abstractmethods(cls: type[_T]) -> type[_T]: ...

stdlib/aifc.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from _typeshed import Self
33
from types import TracebackType
4-
from typing import IO, Any, NamedTuple, Type, Union, overload
4+
from typing import IO, Any, NamedTuple, Union, overload
55
from typing_extensions import Literal
66

77
class Error(Exception): ...
@@ -21,7 +21,7 @@ class Aifc_read:
2121
def __init__(self, f: _File) -> None: ...
2222
def __enter__(self: Self) -> Self: ...
2323
def __exit__(
24-
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
24+
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
2525
) -> None: ...
2626
def initfp(self, file: IO[bytes]) -> None: ...
2727
def getfp(self) -> IO[bytes]: ...
@@ -45,7 +45,7 @@ class Aifc_write:
4545
def __del__(self) -> None: ...
4646
def __enter__(self: Self) -> Self: ...
4747
def __exit__(
48-
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
48+
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
4949
) -> None: ...
5050
def initfp(self, file: IO[bytes]) -> None: ...
5151
def aiff(self) -> None: ...

stdlib/argparse.pyi

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from typing import IO, Any, Callable, Generator, Generic, Iterable, NoReturn, Pattern, Protocol, Sequence, Type, TypeVar, overload
2+
from typing import IO, Any, Callable, Generator, Generic, Iterable, NoReturn, Pattern, Protocol, Sequence, TypeVar, overload
33

44
_T = TypeVar("_T")
55
_ActionT = TypeVar("_ActionT", bound=Action)
@@ -47,7 +47,7 @@ class _ActionsContainer:
4747
def add_argument(
4848
self,
4949
*name_or_flags: str,
50-
action: str | Type[Action] = ...,
50+
action: str | type[Action] = ...,
5151
nargs: int | str = ...,
5252
const: Any = ...,
5353
default: Any = ...,
@@ -67,7 +67,7 @@ class _ActionsContainer:
6767
def _add_container_actions(self, container: _ActionsContainer) -> None: ...
6868
def _get_positional_kwargs(self, dest: str, **kwargs: Any) -> dict[str, Any]: ...
6969
def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
70-
def _pop_action_class(self, kwargs: Any, default: Type[Action] | None = ...) -> Type[Action]: ...
70+
def _pop_action_class(self, kwargs: Any, default: type[Action] | None = ...) -> type[Action]: ...
7171
def _get_handler(self) -> Callable[[Action, Iterable[tuple[str, Action]]], Any]: ...
7272
def _check_conflict(self, action: Action) -> None: ...
7373
def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> NoReturn: ...
@@ -143,7 +143,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
143143
title: str = ...,
144144
description: str | None = ...,
145145
prog: str = ...,
146-
action: Type[Action] = ...,
146+
action: type[Action] = ...,
147147
option_string: str = ...,
148148
dest: str | None = ...,
149149
required: bool = ...,
@@ -157,8 +157,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
157157
title: str = ...,
158158
description: str | None = ...,
159159
prog: str = ...,
160-
parser_class: Type[_ArgumentParserT] = ...,
161-
action: Type[Action] = ...,
160+
parser_class: type[_ArgumentParserT] = ...,
161+
action: type[Action] = ...,
162162
option_string: str = ...,
163163
dest: str | None = ...,
164164
required: bool = ...,
@@ -173,7 +173,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
173173
title: str = ...,
174174
description: str | None = ...,
175175
prog: str = ...,
176-
action: Type[Action] = ...,
176+
action: type[Action] = ...,
177177
option_string: str = ...,
178178
dest: str | None = ...,
179179
help: str | None = ...,
@@ -186,8 +186,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
186186
title: str = ...,
187187
description: str | None = ...,
188188
prog: str = ...,
189-
parser_class: Type[_ArgumentParserT] = ...,
190-
action: Type[Action] = ...,
189+
parser_class: type[_ArgumentParserT] = ...,
190+
action: type[Action] = ...,
191191
option_string: str = ...,
192192
dest: str | None = ...,
193193
help: str | None = ...,
@@ -237,7 +237,7 @@ class HelpFormatter:
237237
_current_section: Any
238238
_whitespace_matcher: Pattern[str]
239239
_long_break_matcher: Pattern[str]
240-
_Section: Type[Any] # Nested class
240+
_Section: type[Any] # Nested class
241241
def __init__(self, prog: str, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ...) -> None: ...
242242
def _indent(self) -> None: ...
243243
def _dedent(self) -> None: ...
@@ -410,9 +410,9 @@ class _VersionAction(Action):
410410

411411
# undocumented
412412
class _SubParsersAction(Action, Generic[_ArgumentParserT]):
413-
_ChoicesPseudoAction: Type[Any] # nested class
413+
_ChoicesPseudoAction: type[Any] # nested class
414414
_prog_prefix: str
415-
_parser_class: Type[_ArgumentParserT]
415+
_parser_class: type[_ArgumentParserT]
416416
_name_parser_map: dict[str, _ArgumentParserT]
417417
choices: dict[str, _ArgumentParserT]
418418
_choices_actions: list[Action]
@@ -421,7 +421,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
421421
self,
422422
option_strings: Sequence[str],
423423
prog: str,
424-
parser_class: Type[_ArgumentParserT],
424+
parser_class: type[_ArgumentParserT],
425425
dest: str = ...,
426426
required: bool = ...,
427427
help: str | None = ...,
@@ -432,7 +432,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
432432
self,
433433
option_strings: Sequence[str],
434434
prog: str,
435-
parser_class: Type[_ArgumentParserT],
435+
parser_class: type[_ArgumentParserT],
436436
dest: str = ...,
437437
help: str | None = ...,
438438
metavar: str | tuple[str, ...] | None = ...,

stdlib/asyncio/__init__.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import sys
2-
from typing import Type
32

43
from .base_events import BaseEventLoop as BaseEventLoop
54
from .coroutines import iscoroutine as iscoroutine, iscoroutinefunction as iscoroutinefunction
@@ -108,7 +107,7 @@ if sys.version_info >= (3, 7):
108107
current_task as current_task,
109108
)
110109

111-
DefaultEventLoopPolicy: Type[AbstractEventLoopPolicy]
110+
DefaultEventLoopPolicy: type[AbstractEventLoopPolicy]
112111

113112
if sys.platform == "win32":
114113
from .windows_events import *

stdlib/asyncio/locks.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from collections import deque
33
from types import TracebackType
4-
from typing import Any, Awaitable, Callable, Generator, Type, TypeVar
4+
from typing import Any, Awaitable, Callable, Generator, TypeVar
55

66
from .events import AbstractEventLoop
77
from .futures import Future
@@ -13,7 +13,7 @@ if sys.version_info >= (3, 9):
1313
def __init__(self, lock: Lock | Semaphore) -> None: ...
1414
def __aenter__(self) -> Awaitable[None]: ...
1515
def __aexit__(
16-
self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
16+
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
1717
) -> Awaitable[None]: ...
1818

1919
else:
@@ -30,7 +30,7 @@ else:
3030
def __await__(self) -> Generator[Any, None, _ContextManager]: ...
3131
def __aenter__(self) -> Awaitable[None]: ...
3232
def __aexit__(
33-
self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
33+
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
3434
) -> Awaitable[None]: ...
3535

3636
class Lock(_ContextManagerMixin):

stdlib/asyncio/proactor_events.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import sys
22
from socket import socket
3-
from typing import Any, Mapping, Protocol, Type
3+
from typing import Any, Mapping, Protocol
44
from typing_extensions import Literal
55

66
from . import base_events, constants, events, futures, streams, transports
77

88
if sys.version_info >= (3, 8):
99
class _WarnCallbackProtocol(Protocol):
1010
def __call__(
11-
self, message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...
11+
self, message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...
1212
) -> None: ...
1313

1414
class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport):

stdlib/asyncio/trsock.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import socket
22
import sys
3+
from builtins import type as Type # alias to avoid name clashes with property named "type"
34
from types import TracebackType
4-
from typing import Any, BinaryIO, Iterable, NoReturn, Type, Union, overload
5+
from typing import Any, BinaryIO, Iterable, NoReturn, Union, overload
56

67
if sys.version_info >= (3, 8):
78
# These are based in socket, maybe move them out into _typeshed.pyi or such

0 commit comments

Comments
 (0)