Skip to content

Use lowercase type everywhere #6853

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
Jan 8, 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
4 changes: 2 additions & 2 deletions stdlib/_compression.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from _typeshed import WriteableBuffer
from io import BufferedIOBase, RawIOBase
from typing import Any, Callable, Protocol, Type
from typing import Any, Callable, Protocol

BUFFER_SIZE: Any

Expand All @@ -16,7 +16,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
4 changes: 2 additions & 2 deletions stdlib/_csv.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Iterable, Iterator, Protocol, Type, Union
from typing import Any, Iterable, Iterator, Protocol, Union
from typing_extensions import Literal

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

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

class _reader(Iterator[list[str]]):
dialect: Dialect
Expand Down
10 changes: 5 additions & 5 deletions stdlib/_dummy_threading.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from types import FrameType, TracebackType
from typing import Any, Callable, Iterable, Mapping, Optional, Type, TypeVar
from typing import Any, Callable, Iterable, Mapping, Optional, TypeVar

# TODO recursive type
_TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]]
Expand Down Expand Up @@ -67,7 +67,7 @@ class Lock:
def __init__(self) -> None: ...
def __enter__(self) -> bool: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
def release(self) -> None: ...
Expand All @@ -77,7 +77,7 @@ class _RLock:
def __init__(self) -> None: ...
def __enter__(self) -> bool: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
def release(self) -> None: ...
Expand All @@ -88,7 +88,7 @@ class Condition:
def __init__(self, lock: Lock | _RLock | None = ...) -> None: ...
def __enter__(self) -> bool: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
def release(self) -> None: ...
Expand All @@ -101,7 +101,7 @@ class Condition:
class Semaphore:
def __init__(self, value: int = ...) -> None: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
def acquire(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ...
def __enter__(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ...
Expand Down
6 changes: 3 additions & 3 deletions stdlib/_py_abc.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Any, Type, TypeVar
from typing import Any, 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 register(cls, subclass: Type[_T]) -> Type[_T]: ...
def __new__(__mcls, __name: str, __bases: tuple[type[Any], ...], __namespace: dict[str, Any]) -> ABCMeta: ...
def register(cls, subclass: type[_T]) -> type[_T]: ...
8 changes: 4 additions & 4 deletions stdlib/_thread.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sys
from _typeshed import structseq
from threading import Thread
from types import TracebackType
from typing import Any, Callable, NoReturn, Optional, Type
from typing import Any, Callable, NoReturn, Optional
from typing_extensions import final

error = RuntimeError
Expand All @@ -18,7 +18,7 @@ class LockType:
def locked(self) -> bool: ...
def __enter__(self) -> bool: ...
def __exit__(
self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
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: ...
Expand All @@ -34,10 +34,10 @@ 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]: ...
def exc_type(self) -> type[BaseException]: ...
@property
def exc_value(self) -> BaseException | None: ...
@property
Expand Down
4 changes: 2 additions & 2 deletions stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ctypes
import mmap
import sys
from os import PathLike
from typing import AbstractSet, Any, Awaitable, Container, Generic, Iterable, Protocol, Type, TypeVar, Union
from typing import AbstractSet, Any, Awaitable, Container, Generic, Iterable, Protocol, TypeVar, Union
from typing_extensions import Final, Literal, final

_KT = TypeVar("_KT")
Expand Down Expand Up @@ -215,4 +215,4 @@ class structseq(Generic[_T_co]):
# The second parameter will accept a dict of any kind without raising an exception,
# but only has any meaning if you supply it a dict where the keys are strings.
# https://github.com/python/typeshed/pull/6560#discussion_r767149830
def __new__(cls: Type[_T], sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> _T: ...
def __new__(cls: type[_T], sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> _T: ...
12 changes: 6 additions & 6 deletions stdlib/_warnings.pyi
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from typing import Any, Type, overload
from typing import Any, overload

_defaultaction: str
_onceregistry: dict[Any, Any]
filters: list[tuple[str, str | None, Type[Warning], str | None, int]]
filters: list[tuple[str, str | None, type[Warning], str | None, int]]

@overload
def warn(message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ...
def warn(message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ...
@overload
def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ...
@overload
def warn_explicit(
message: str,
category: Type[Warning],
category: type[Warning],
filename: str,
lineno: int,
module: str | None = ...,
registry: dict[str | tuple[str, Type[Warning], int], int] | None = ...,
registry: dict[str | tuple[str, type[Warning], int], int] | None = ...,
module_globals: dict[str, Any] | None = ...,
source: Any | None = ...,
) -> None: ...
Expand All @@ -26,7 +26,7 @@ def warn_explicit(
filename: str,
lineno: int,
module: str | None = ...,
registry: dict[str | tuple[str, Type[Warning], int], int] | None = ...,
registry: dict[str | tuple[str, type[Warning], int], int] | None = ...,
module_globals: dict[str, Any] | None = ...,
source: Any | None = ...,
) -> None: ...
6 changes: 3 additions & 3 deletions stdlib/abc.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from _typeshed import SupportsWrite
from typing import Any, Callable, Type, TypeVar
from typing import Any, Callable, TypeVar

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

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

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

if sys.version_info >= (3, 10):
def update_abstractmethods(cls: Type[_T]) -> Type[_T]: ...
def update_abstractmethods(cls: type[_T]) -> type[_T]: ...
6 changes: 3 additions & 3 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, Type, Union, overload
from typing import IO, Any, NamedTuple, Union, overload
from typing_extensions import Literal

class Error(Exception): ...
Expand All @@ -21,7 +21,7 @@ class Aifc_read:
def __init__(self, f: _File) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def initfp(self, file: IO[bytes]) -> None: ...
def getfp(self) -> IO[bytes]: ...
Expand All @@ -45,7 +45,7 @@ class Aifc_write:
def __del__(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def initfp(self, file: IO[bytes]) -> None: ...
def aiff(self) -> None: ...
Expand Down
28 changes: 14 additions & 14 deletions stdlib/argparse.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import IO, Any, Callable, Generator, Generic, Iterable, NoReturn, Pattern, Protocol, Sequence, Type, TypeVar, overload
from typing import IO, Any, Callable, Generator, Generic, Iterable, NoReturn, Pattern, Protocol, Sequence, TypeVar, overload

_T = TypeVar("_T")
_ActionT = TypeVar("_ActionT", bound=Action)
Expand Down Expand Up @@ -47,7 +47,7 @@ class _ActionsContainer:
def add_argument(
self,
*name_or_flags: str,
action: str | Type[Action] = ...,
action: str | type[Action] = ...,
nargs: int | str = ...,
const: Any = ...,
default: Any = ...,
Expand All @@ -67,7 +67,7 @@ class _ActionsContainer:
def _add_container_actions(self, container: _ActionsContainer) -> None: ...
def _get_positional_kwargs(self, dest: str, **kwargs: Any) -> dict[str, Any]: ...
def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
def _pop_action_class(self, kwargs: Any, default: Type[Action] | None = ...) -> Type[Action]: ...
def _pop_action_class(self, kwargs: Any, default: type[Action] | None = ...) -> type[Action]: ...
def _get_handler(self) -> Callable[[Action, Iterable[tuple[str, Action]]], Any]: ...
def _check_conflict(self, action: Action) -> None: ...
def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> NoReturn: ...
Expand Down Expand Up @@ -143,7 +143,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
title: str = ...,
description: str | None = ...,
prog: str = ...,
action: Type[Action] = ...,
action: type[Action] = ...,
option_string: str = ...,
dest: str | None = ...,
required: bool = ...,
Expand All @@ -157,8 +157,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
title: str = ...,
description: str | None = ...,
prog: str = ...,
parser_class: Type[_ArgumentParserT] = ...,
action: Type[Action] = ...,
parser_class: type[_ArgumentParserT] = ...,
action: type[Action] = ...,
option_string: str = ...,
dest: str | None = ...,
required: bool = ...,
Expand All @@ -173,7 +173,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
title: str = ...,
description: str | None = ...,
prog: str = ...,
action: Type[Action] = ...,
action: type[Action] = ...,
option_string: str = ...,
dest: str | None = ...,
help: str | None = ...,
Expand All @@ -186,8 +186,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
title: str = ...,
description: str | None = ...,
prog: str = ...,
parser_class: Type[_ArgumentParserT] = ...,
action: Type[Action] = ...,
parser_class: type[_ArgumentParserT] = ...,
action: type[Action] = ...,
option_string: str = ...,
dest: str | None = ...,
help: str | None = ...,
Expand Down Expand Up @@ -237,7 +237,7 @@ class HelpFormatter:
_current_section: Any
_whitespace_matcher: Pattern[str]
_long_break_matcher: Pattern[str]
_Section: Type[Any] # Nested class
_Section: type[Any] # Nested class
def __init__(self, prog: str, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ...) -> None: ...
def _indent(self) -> None: ...
def _dedent(self) -> None: ...
Expand Down Expand Up @@ -410,9 +410,9 @@ class _VersionAction(Action):

# undocumented
class _SubParsersAction(Action, Generic[_ArgumentParserT]):
_ChoicesPseudoAction: Type[Any] # nested class
_ChoicesPseudoAction: type[Any] # nested class
_prog_prefix: str
_parser_class: Type[_ArgumentParserT]
_parser_class: type[_ArgumentParserT]
_name_parser_map: dict[str, _ArgumentParserT]
choices: dict[str, _ArgumentParserT]
_choices_actions: list[Action]
Expand All @@ -421,7 +421,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
self,
option_strings: Sequence[str],
prog: str,
parser_class: Type[_ArgumentParserT],
parser_class: type[_ArgumentParserT],
dest: str = ...,
required: bool = ...,
help: str | None = ...,
Expand All @@ -432,7 +432,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
self,
option_strings: Sequence[str],
prog: str,
parser_class: Type[_ArgumentParserT],
parser_class: type[_ArgumentParserT],
dest: str = ...,
help: str | None = ...,
metavar: str | tuple[str, ...] | None = ...,
Expand Down
3 changes: 1 addition & 2 deletions stdlib/asyncio/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
from typing import Type

from .base_events import BaseEventLoop as BaseEventLoop
from .coroutines import iscoroutine as iscoroutine, iscoroutinefunction as iscoroutinefunction
Expand Down Expand Up @@ -108,7 +107,7 @@ if sys.version_info >= (3, 7):
current_task as current_task,
)

DefaultEventLoopPolicy: Type[AbstractEventLoopPolicy]
DefaultEventLoopPolicy: type[AbstractEventLoopPolicy]

if sys.platform == "win32":
from .windows_events import *
Expand Down
6 changes: 3 additions & 3 deletions stdlib/asyncio/locks.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from collections import deque
from types import TracebackType
from typing import Any, Awaitable, Callable, Generator, Type, TypeVar
from typing import Any, Awaitable, Callable, Generator, TypeVar

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

else:
Expand All @@ -30,7 +30,7 @@ else:
def __await__(self) -> Generator[Any, None, _ContextManager]: ...
def __aenter__(self) -> Awaitable[None]: ...
def __aexit__(
self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
) -> Awaitable[None]: ...

class Lock(_ContextManagerMixin):
Expand Down
4 changes: 2 additions & 2 deletions stdlib/asyncio/proactor_events.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import sys
from socket import socket
from typing import Any, Mapping, Protocol, Type
from typing import Any, Mapping, Protocol
from typing_extensions import Literal

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

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

class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport):
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/trsock.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import socket
import sys
from builtins import type as Type # alias to avoid name clashes with property named "type"
from types import TracebackType
from typing import Any, BinaryIO, Iterable, NoReturn, Type, Union, overload
from typing import Any, BinaryIO, Iterable, NoReturn, Union, overload

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