diff --git a/stdlib/_compression.pyi b/stdlib/_compression.pyi index 31940e3eb..15d7074e4 100644 --- a/stdlib/_compression.pyi +++ b/stdlib/_compression.pyi @@ -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 @@ -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: ... diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index b0d1cccda..051a5fb81 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -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] @@ -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 diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index 075ea4637..e7a830f4a 100644 --- a/stdlib/_dummy_threading.pyi +++ b/stdlib/_dummy_threading.pyi @@ -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]]] @@ -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: ... @@ -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: ... @@ -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: ... @@ -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: ... diff --git a/stdlib/_py_abc.pyi b/stdlib/_py_abc.pyi index 697a7f171..42f36d1b3 100644 --- a/stdlib/_py_abc.pyi +++ b/stdlib/_py_abc.pyi @@ -1,4 +1,4 @@ -from typing import Any, Type, TypeVar +from typing import Any, TypeVar _T = TypeVar("_T") @@ -6,5 +6,5 @@ _T = TypeVar("_T") 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]: ... diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 03318a0b2..744799f1f 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -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 @@ -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: ... @@ -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 diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index c52f3e0da..fdc889c6b 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -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") @@ -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: ... diff --git a/stdlib/_warnings.pyi b/stdlib/_warnings.pyi index e5b180b14..2eb9ae478 100644 --- a/stdlib/_warnings.pyi +++ b/stdlib/_warnings.pyi @@ -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: ... @@ -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: ... diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index 3c53692e1..33a53cc74 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -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]) @@ -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: ... @@ -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]: ... diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index e19bf2478..f88459bef 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -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): ... @@ -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]: ... @@ -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: ... diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 51933dc66..b0020c1cd 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -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) @@ -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 = ..., @@ -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: ... @@ -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 = ..., @@ -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 = ..., @@ -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 = ..., @@ -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 = ..., @@ -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: ... @@ -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] @@ -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 = ..., @@ -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 = ..., diff --git a/stdlib/asyncio/__init__.pyi b/stdlib/asyncio/__init__.pyi index f2f7c6b0d..e75874627 100644 --- a/stdlib/asyncio/__init__.pyi +++ b/stdlib/asyncio/__init__.pyi @@ -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 @@ -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 * diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 7c4f40d9e..fa1b9235a 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -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 @@ -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: @@ -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): diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index 1e9cff1b1..3c5182a39 100644 --- a/stdlib/asyncio/proactor_events.pyi +++ b/stdlib/asyncio/proactor_events.pyi @@ -1,6 +1,6 @@ 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 @@ -8,7 +8,7 @@ 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): diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 55147f4fd..e6d617de7 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -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 diff --git a/stdlib/asyncio/unix_events.pyi b/stdlib/asyncio/unix_events.pyi index de3b320a4..d4c1c546d 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -2,7 +2,7 @@ import sys import types from _typeshed import Self from socket import socket -from typing import Any, Callable, Type +from typing import Any, Callable from .base_events import Server from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy, _ProtocolFactory, _SSLContext @@ -17,7 +17,7 @@ class AbstractChildWatcher: def attach_loop(self, loop: AbstractEventLoop | None) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... + def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... if sys.version_info >= (3, 8): def is_active(self) -> bool: ... @@ -51,7 +51,7 @@ if sys.platform != "win32": from typing import Protocol class _Warn(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 MultiLoopChildWatcher(AbstractChildWatcher): def __enter__(self: Self) -> Self: ... diff --git a/stdlib/asyncio/windows_events.pyi b/stdlib/asyncio/windows_events.pyi index d86b6af91..1bb49c965 100644 --- a/stdlib/asyncio/windows_events.pyi +++ b/stdlib/asyncio/windows_events.pyi @@ -1,7 +1,7 @@ import socket import sys from _typeshed import WriteableBuffer -from typing import IO, Any, Callable, ClassVar, NoReturn, Type +from typing import IO, Any, Callable, ClassVar, NoReturn from typing_extensions import Literal from . import events, futures, proactor_events, selector_events, streams, windows_utils @@ -61,17 +61,17 @@ if sys.platform == "win32": if sys.version_info >= (3, 7): class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[Type[SelectorEventLoop]] + _loop_factory: ClassVar[type[SelectorEventLoop]] def get_child_watcher(self) -> NoReturn: ... def set_child_watcher(self, watcher: Any) -> NoReturn: ... class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[Type[ProactorEventLoop]] + _loop_factory: ClassVar[type[ProactorEventLoop]] def get_child_watcher(self) -> NoReturn: ... def set_child_watcher(self, watcher: Any) -> NoReturn: ... DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy else: class _WindowsDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy): - _loop_factory: ClassVar[Type[SelectorEventLoop]] + _loop_factory: ClassVar[type[SelectorEventLoop]] def get_child_watcher(self) -> NoReturn: ... def set_child_watcher(self, watcher: Any) -> NoReturn: ... DefaultEventLoopPolicy = _WindowsDefaultEventLoopPolicy diff --git a/stdlib/asyncio/windows_utils.pyi b/stdlib/asyncio/windows_utils.pyi index c387fc40f..5d07362fa 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -2,13 +2,13 @@ import subprocess import sys from _typeshed import Self from types import TracebackType -from typing import Callable, Protocol, Type +from typing import Callable, Protocol from typing_extensions import Literal if sys.platform == "win32": class _WarnFunction(Protocol): def __call__( - self, message: str, category: Type[Warning] = ..., stacklevel: int = ..., source: PipeHandle = ... + self, message: str, category: type[Warning] = ..., stacklevel: int = ..., source: PipeHandle = ... ) -> None: ... BUFSIZE: Literal[8192] PIPE = subprocess.PIPE diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index 3f6b6d3d8..993f0c6e2 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -1,9 +1,9 @@ from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, Type, TypeVar +from typing import IO, Any, Callable, Iterable, Mapping, SupportsInt, TypeVar _T = TypeVar("_T") _TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type -_ExcInfo = tuple[Type[BaseException], BaseException, FrameType] +_ExcInfo = tuple[type[BaseException], BaseException, FrameType] GENERATOR_AND_COROUTINE_FLAGS: int diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 6a9a05e86..37c2d056e 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -49,7 +49,6 @@ from typing import ( SupportsFloat, SupportsInt, SupportsRound, - Type, TypeVar, Union, overload, @@ -89,12 +88,12 @@ class object: __module__: str __annotations__: dict[str, Any] @property - def __class__(self: _T) -> Type[_T]: ... + def __class__(self: _T) -> type[_T]: ... # Ignore errors about type mismatch between property getter and setter @__class__.setter - def __class__(self, __type: Type[object]) -> None: ... # type: ignore # noqa: F811 + def __class__(self, __type: type[object]) -> None: ... # type: ignore # noqa: F811 def __init__(self) -> None: ... - def __new__(cls: Type[_T]) -> _T: ... + def __new__(cls: type[_T]) -> _T: ... def __setattr__(self, __name: str, __value: Any) -> None: ... def __eq__(self, __o: object) -> bool: ... def __ne__(self, __o: object) -> bool: ... @@ -119,8 +118,8 @@ class staticmethod(Generic[_R]): # Special, only valid as a decorator. __func__: Callable[..., _R] __isabstractmethod__: bool def __init__(self: staticmethod[_R], __f: Callable[..., _R]) -> None: ... - def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, __obj: _T, __type: Type[_T] | None = ...) -> Callable[..., _R]: ... + def __new__(cls: type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, __obj: _T, __type: type[_T] | None = ...) -> Callable[..., _R]: ... if sys.version_info >= (3, 10): __name__: str __qualname__: str @@ -131,8 +130,8 @@ class classmethod(Generic[_R]): # Special, only valid as a decorator. __func__: Callable[..., _R] __isabstractmethod__: bool def __init__(self: classmethod[_R], __f: Callable[..., _R]) -> None: ... - def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ... - def __get__(self, __obj: _T, __type: Type[_T] | None = ...) -> Callable[..., _R]: ... + def __new__(cls: type[_T], *args: Any, **kwargs: Any) -> _T: ... + def __get__(self, __obj: _T, __type: type[_T] | None = ...) -> Callable[..., _R]: ... if sys.version_info >= (3, 10): __name__: str __qualname__: str @@ -159,7 +158,7 @@ class type: @overload def __new__(cls, __o: object) -> type: ... @overload - def __new__(cls: Type[_TT], __name: str, __bases: tuple[type, ...], __namespace: dict[str, Any], **kwds: Any) -> _TT: ... + def __new__(cls: type[_TT], __name: str, __bases: tuple[type, ...], __namespace: dict[str, Any], **kwds: Any) -> _TT: ... def __call__(self, *args: Any, **kwds: Any) -> Any: ... def __subclasses__(self: _TT) -> list[_TT]: ... # Note: the documentation doesn't specify what the return type is, the standard @@ -186,9 +185,9 @@ _NegativeInteger = Literal[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -1 class int: @overload - def __new__(cls: Type[_T], __x: str | bytes | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> _T: ... + def __new__(cls: type[_T], __x: str | bytes | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> _T: ... @overload - def __new__(cls: Type[_T], __x: str | bytes | bytearray, base: SupportsIndex) -> _T: ... + def __new__(cls: type[_T], __x: str | bytes | bytearray, base: SupportsIndex) -> _T: ... if sys.version_info >= (3, 8): def as_integer_ratio(self) -> tuple[int, Literal[1]]: ... @property @@ -206,7 +205,7 @@ class int: def to_bytes(self, length: SupportsIndex, byteorder: Literal["little", "big"], *, signed: bool = ...) -> bytes: ... @classmethod def from_bytes( - cls: Type[Self], + cls: type[Self], bytes: Iterable[SupportsIndex] | SupportsBytes, # TODO buffer object argument byteorder: Literal["little", "big"], *, @@ -272,12 +271,12 @@ class int: def __index__(self) -> int: ... class float: - def __new__(cls: Type[_T], x: SupportsFloat | SupportsIndex | str | bytes | bytearray = ...) -> _T: ... + def __new__(cls: type[_T], x: SupportsFloat | SupportsIndex | str | bytes | bytearray = ...) -> _T: ... def as_integer_ratio(self) -> tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @classmethod - def fromhex(cls: Type[Self], __s: str) -> Self: ... + def fromhex(cls: type[Self], __s: str) -> Self: ... @property def real(self) -> float: ... @property @@ -330,9 +329,9 @@ class float: class complex: @overload - def __new__(cls: Type[_T], real: float = ..., imag: float = ...) -> _T: ... + def __new__(cls: type[_T], real: float = ..., imag: float = ...) -> _T: ... @overload - def __new__(cls: Type[_T], real: str | SupportsComplex | SupportsIndex | complex) -> _T: ... + def __new__(cls: type[_T], real: str | SupportsComplex | SupportsIndex | complex) -> _T: ... @property def real(self) -> float: ... @property @@ -364,9 +363,9 @@ class _FormatMapMapping(Protocol): class str(Sequence[str]): @overload - def __new__(cls: Type[_T], object: object = ...) -> _T: ... + def __new__(cls: type[_T], object: object = ...) -> _T: ... @overload - def __new__(cls: Type[_T], o: bytes, encoding: str = ..., errors: str = ...) -> _T: ... + def __new__(cls: type[_T], o: bytes, encoding: str = ..., errors: str = ...) -> _T: ... def capitalize(self) -> str: ... def casefold(self) -> str: ... def center(self, __width: SupportsIndex, __fillchar: str = ...) -> str: ... @@ -450,15 +449,15 @@ class str(Sequence[str]): class bytes(ByteString): @overload - def __new__(cls: Type[_T], __ints: Iterable[SupportsIndex]) -> _T: ... + def __new__(cls: type[_T], __ints: Iterable[SupportsIndex]) -> _T: ... @overload - def __new__(cls: Type[_T], __string: str, encoding: str, errors: str = ...) -> _T: ... + def __new__(cls: type[_T], __string: str, encoding: str, errors: str = ...) -> _T: ... @overload - def __new__(cls: Type[_T], __length: SupportsIndex) -> _T: ... + def __new__(cls: type[_T], __length: SupportsIndex) -> _T: ... @overload - def __new__(cls: Type[_T]) -> _T: ... + def __new__(cls: type[_T]) -> _T: ... @overload - def __new__(cls: Type[_T], __o: SupportsBytes) -> _T: ... + def __new__(cls: type[_T], __o: SupportsBytes) -> _T: ... def capitalize(self) -> bytes: ... def center(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... def count( @@ -522,7 +521,7 @@ class bytes(ByteString): def upper(self) -> bytes: ... def zfill(self, __width: SupportsIndex) -> bytes: ... @classmethod - def fromhex(cls: Type[Self], __s: str) -> Self: ... + def fromhex(cls: type[Self], __s: str) -> Self: ... @staticmethod def maketrans(__frm: bytes, __to: bytes) -> bytes: ... def __len__(self) -> int: ... @@ -626,7 +625,7 @@ class bytearray(MutableSequence[int], ByteString): def upper(self) -> bytearray: ... def zfill(self, __width: SupportsIndex) -> bytearray: ... @classmethod - def fromhex(cls: Type[Self], __string: str) -> Self: ... + def fromhex(cls: type[Self], __string: str) -> Self: ... @staticmethod def maketrans(__frm: bytes, __to: bytes) -> bytes: ... def __len__(self) -> int: ... @@ -676,7 +675,7 @@ class memoryview(Sized, Sequence[int]): def __init__(self, obj: ReadableBuffer) -> 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 cast(self, format: str, shape: list[int] | tuple[int, ...] = ...) -> memoryview: ... @overload @@ -705,7 +704,7 @@ class memoryview(Sized, Sequence[int]): @final class bool(int): - def __new__(cls: Type[_T], __o: object = ...) -> _T: ... + def __new__(cls: type[_T], __o: object = ...) -> _T: ... @overload def __and__(self, __x: bool) -> bool: ... @overload @@ -748,7 +747,7 @@ class slice: def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ... class tuple(Sequence[_T_co], Generic[_T_co]): - def __new__(cls: Type[_T], __iterable: Iterable[_T_co] = ...) -> _T: ... + def __new__(cls: type[_T], __iterable: Iterable[_T_co] = ...) -> _T: ... def __len__(self) -> int: ... def __contains__(self, __x: object) -> bool: ... @overload @@ -848,7 +847,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): # Cannot be Iterable[Sequence[_T]] or otherwise dict(["foo", "bar", "baz"]) is not an error @overload def __init__(self: dict[str, str], __iterable: Iterable[list[str]]) -> None: ... - def __new__(cls: Type[_T1], *args: Any, **kwargs: Any) -> _T1: ... + def __new__(cls: type[_T1], *args: Any, **kwargs: Any) -> _T1: ... def copy(self) -> dict[_KT, _VT]: ... def keys(self) -> dict_keys[_KT, _VT]: ... def values(self) -> dict_values[_KT, _VT]: ... diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index a8f3912aa..3a551e310 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -1,8 +1,8 @@ from _typeshed import StrOrBytesPath from types import FrameType, TracebackType -from typing import IO, Any, Callable, Optional, Type +from typing import IO, Any, Callable, Optional -_ExcInfo = tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_ExcInfo = tuple[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]] def reset() -> str: ... # undocumented def small(text: str) -> str: ... # undocumented @@ -24,7 +24,7 @@ class Hook: # undocumented file: IO[str] | None = ..., format: str = ..., ) -> None: ... - def __call__(self, etype: Type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None) -> None: ... + def __call__(self, etype: type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None) -> None: ... def handle(self, info: _ExcInfo | None = ...) -> None: ... def handler(info: _ExcInfo | None = ...) -> None: ... diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index a07ffcfc5..aec5484d2 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -2,7 +2,7 @@ import sys import types from _typeshed import Self from abc import abstractmethod -from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, TextIO, Type, TypeVar, overload +from typing import IO, Any, BinaryIO, Callable, Generator, Iterable, Iterator, Protocol, TextIO, TypeVar, overload from typing_extensions import Literal BOM32_BE: Literal[b"\xfe\xff"] @@ -186,7 +186,7 @@ class StreamWriter(Codec): def writelines(self, list: Iterable[str]) -> None: ... def reset(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... + def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... class StreamReader(Codec): @@ -197,7 +197,7 @@ class StreamReader(Codec): def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> list[str]: ... def reset(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... + def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __iter__(self) -> Iterator[str]: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -219,7 +219,7 @@ class StreamReaderWriter(TextIO): # Same as write() def seek(self, offset: int, whence: int = ...) -> int: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... + def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __getattr__(self, name: str) -> Any: ... # These methods don't actually exist directly, but they are needed to satisfy the TextIO # interface. At runtime, they are delegated through __getattr__. @@ -255,7 +255,7 @@ class StreamRecoder(BinaryIO): def reset(self) -> None: ... def __getattr__(self, name: str) -> Any: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, type: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ... + def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ... # These methods don't actually exist directly, but they are needed to satisfy the BinaryIO # interface. At runtime, they are delegated through __getattr__. def seek(self, offset: int, whence: int = ...) -> int: ... diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 1a4c4b425..2c30602da 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,7 +1,7 @@ import sys from _collections_abc import dict_items, dict_keys, dict_values from _typeshed import Self, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT -from typing import Any, Generic, NoReturn, Type, TypeVar, overload +from typing import Any, Generic, NoReturn, TypeVar, overload from typing_extensions import SupportsIndex, final if sys.version_info >= (3, 9): @@ -28,12 +28,12 @@ if sys.version_info >= (3, 7): rename: bool = ..., module: str | None = ..., defaults: Iterable[Any] | None = ..., - ) -> Type[tuple[Any, ...]]: ... + ) -> type[tuple[Any, ...]]: ... else: def namedtuple( typename: str, field_names: str | Iterable[str], *, verbose: bool = ..., rename: bool = ..., module: str | None = ... - ) -> Type[tuple[Any, ...]]: ... + ) -> type[tuple[Any, ...]]: ... class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): data: dict[_KT, _VT] @@ -206,7 +206,7 @@ class deque(MutableSequence[_T], Generic[_T]): def __setitem__(self, __i: SupportsIndex, __x: _T) -> None: ... # type: ignore[override] def __delitem__(self, __i: SupportsIndex) -> None: ... # type: ignore[override] def __contains__(self, __o: object) -> bool: ... - def __reduce__(self: Self) -> tuple[Type[Self], tuple[()], None, Iterator[_T]]: ... + def __reduce__(self: Self) -> tuple[type[Self], tuple[()], None, Iterator[_T]]: ... def __iadd__(self: _S, __iterable: Iterable[_T]) -> _S: ... def __add__(self: _S, __other: _S) -> _S: ... def __mul__(self: _S, __other: int) -> _S: ... diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index dc81cb785..e27e12ede 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath, StrPath, SupportsWrite from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence -from typing import Any, ClassVar, Optional, Pattern, Type, TypeVar, overload +from typing import Any, ClassVar, Optional, Pattern, TypeVar, overload from typing_extensions import Literal # Internal type aliases @@ -47,7 +47,7 @@ class RawConfigParser(_parser): def __init__( self, defaults: Mapping[str, str | None] | None = ..., - dict_type: Type[Mapping[str, str]] = ..., + dict_type: type[Mapping[str, str]] = ..., allow_no_value: Literal[True] = ..., *, delimiters: Sequence[str] = ..., @@ -63,7 +63,7 @@ class RawConfigParser(_parser): def __init__( self, defaults: _section | None = ..., - dict_type: Type[Mapping[str, str]] = ..., + dict_type: type[Mapping[str, str]] = ..., allow_no_value: bool = ..., *, delimiters: Sequence[str] = ..., diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index b536c3667..8716dec05 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -14,7 +14,6 @@ from typing import ( Iterator, Optional, Protocol, - Type, TypeVar, overload, ) @@ -32,7 +31,7 @@ _T_io = TypeVar("_T_io", bound=Optional[IO[str]]) _F = TypeVar("_F", bound=Callable[..., Any]) _P = ParamSpec("_P") -_ExitFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] +_ExitFunc = Callable[[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] _CM_EF = TypeVar("_CM_EF", AbstractContextManager[Any], _ExitFunc) class ContextDecorator: @@ -90,9 +89,9 @@ if sys.version_info >= (3, 10): def __init__(self, thing: _SupportsAcloseT) -> None: ... class suppress(AbstractContextManager[None]): - def __init__(self, *exceptions: Type[BaseException]) -> None: ... + def __init__(self, *exceptions: type[BaseException]) -> None: ... def __exit__( - self, exctype: Type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None + self, exctype: type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None ) -> bool: ... class redirect_stdout(AbstractContextManager[_T_io]): @@ -110,11 +109,11 @@ class ExitStack(AbstractContextManager[ExitStack]): def close(self) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None + self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> bool: ... if sys.version_info >= (3, 7): - _ExitCoroFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]] + _ExitCoroFunc = Callable[[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]] _CallbackCoroFunc = Callable[..., Awaitable[Any]] _ACM_EF = TypeVar("_ACM_EF", AbstractAsyncContextManager[Any], _ExitCoroFunc) class AsyncExitStack(AbstractAsyncContextManager[AsyncExitStack]): @@ -129,7 +128,7 @@ if sys.version_info >= (3, 7): def aclose(self) -> Awaitable[None]: ... def __aenter__(self: Self) -> Awaitable[Self]: ... def __aexit__( - self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None + self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> Awaitable[bool]: ... if sys.version_info >= (3, 10): diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 63999be05..13dd603d0 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -18,7 +18,7 @@ from _csv import ( writer as writer, ) from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence -from typing import Any, Generic, Type, TypeVar, overload +from typing import Any, Generic, TypeVar, overload if sys.version_info >= (3, 8): from builtins import dict as _DictReadMapping @@ -103,5 +103,5 @@ class DictWriter(Generic[_T]): class Sniffer: preferred: list[str] def __init__(self) -> None: ... - def sniff(self, sample: str, delimiters: str | None = ...) -> Type[Dialect]: ... + def sniff(self, sample: str, delimiters: str | None = ...) -> type[Dialect]: ... def has_header(self, sample: str) -> bool: ... diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 7f2eba011..8af6f1448 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -11,7 +11,6 @@ from typing import ( Mapping, Optional, Sequence, - Type, TypeVar, Union as _UnionT, overload, @@ -33,7 +32,7 @@ class CDLL: _func_restype_: ClassVar[_CData] _name: str _handle: int - _FuncPtr: Type[_FuncPointer] + _FuncPtr: type[_FuncPointer] if sys.version_info >= (3, 8): def __init__( self, @@ -58,7 +57,7 @@ if sys.platform == "win32": class PyDLL(CDLL): ... class LibraryLoader(Generic[_DLLT]): - def __init__(self, dlltype: Type[_DLLT]) -> None: ... + def __init__(self, dlltype: type[_DLLT]) -> None: ... def __getattr__(self, name: str) -> _DLLT: ... def __getitem__(self, name: str) -> _DLLT: ... def LoadLibrary(self, name: str) -> _DLLT: ... @@ -76,33 +75,33 @@ class _CDataMeta(type): # By default mypy complains about the following two methods, because strictly speaking cls # might not be a Type[_CT]. However this can never actually happen, because the only class that # uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here. - def __mul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore[misc] - def __rmul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore[misc] + def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] + def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] class _CData(metaclass=_CDataMeta): _b_base: int _b_needsfree_: bool _objects: Mapping[Any, int] | None @classmethod - def from_buffer(cls: Type[_CT], source: WriteableBuffer, offset: int = ...) -> _CT: ... + def from_buffer(cls: type[_CT], source: WriteableBuffer, offset: int = ...) -> _CT: ... @classmethod - def from_buffer_copy(cls: Type[_CT], source: ReadableBuffer, offset: int = ...) -> _CT: ... + def from_buffer_copy(cls: type[_CT], source: ReadableBuffer, offset: int = ...) -> _CT: ... @classmethod - def from_address(cls: Type[_CT], address: int) -> _CT: ... + def from_address(cls: type[_CT], address: int) -> _CT: ... @classmethod - def from_param(cls: Type[_CT], obj: Any) -> _CT | _CArgObject: ... + def from_param(cls: type[_CT], obj: Any) -> _CT | _CArgObject: ... @classmethod - def in_dll(cls: Type[_CT], library: CDLL, name: str) -> _CT: ... + def in_dll(cls: type[_CT], library: CDLL, name: str) -> _CT: ... class _CanCastTo(_CData): ... class _PointerLike(_CanCastTo): ... -_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, tuple[_CData, ...]], _CData] +_ECT = Callable[[Optional[type[_CData]], _FuncPointer, tuple[_CData, ...]], _CData] _PF = _UnionT[tuple[int], tuple[int, str], tuple[int, str, Any]] class _FuncPointer(_PointerLike, _CData): - restype: Type[_CData] | Callable[[int], Any] | None - argtypes: Sequence[Type[_CData]] + restype: type[_CData] | Callable[[int], Any] | None + argtypes: Sequence[type[_CData]] errcheck: _ECT @overload def __init__(self, address: int) -> None: ... @@ -120,15 +119,15 @@ class _NamedFuncPointer(_FuncPointer): class ArgumentError(Exception): ... def CFUNCTYPE( - restype: Type[_CData] | None, *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... -) -> Type[_FuncPointer]: ... + restype: type[_CData] | None, *argtypes: type[_CData], use_errno: bool = ..., use_last_error: bool = ... +) -> type[_FuncPointer]: ... if sys.platform == "win32": def WINFUNCTYPE( - restype: Type[_CData] | None, *argtypes: Type[_CData], use_errno: bool = ..., use_last_error: bool = ... - ) -> Type[_FuncPointer]: ... + restype: type[_CData] | None, *argtypes: type[_CData], use_errno: bool = ..., use_last_error: bool = ... + ) -> type[_FuncPointer]: ... -def PYFUNCTYPE(restype: Type[_CData] | None, *argtypes: Type[_CData]) -> Type[_FuncPointer]: ... +def PYFUNCTYPE(restype: type[_CData] | None, *argtypes: type[_CData]) -> type[_FuncPointer]: ... class _CArgObject: ... @@ -142,12 +141,12 @@ _CVoidPLike = _UnionT[_PointerLike, Array[Any], _CArgObject, int] _CVoidConstPLike = _UnionT[_CVoidPLike, bytes] def addressof(obj: _CData) -> int: ... -def alignment(obj_or_type: _CData | Type[_CData]) -> int: ... +def alignment(obj_or_type: _CData | type[_CData]) -> int: ... def byref(obj: _CData, offset: int = ...) -> _CArgObject: ... _CastT = TypeVar("_CastT", bound=_CanCastTo) -def cast(obj: _CData | _CArgObject | int, typ: Type[_CastT]) -> _CastT: ... +def cast(obj: _CData | _CArgObject | int, typ: type[_CastT]) -> _CastT: ... def create_string_buffer(init: int | bytes, size: int | None = ...) -> Array[c_char]: ... c_buffer = create_string_buffer @@ -167,13 +166,13 @@ if sys.platform == "win32": def memmove(dst: _CVoidPLike, src: _CVoidConstPLike, count: int) -> None: ... def memset(dst: _CVoidPLike, c: int, count: int) -> None: ... -def POINTER(type: Type[_CT]) -> Type[pointer[_CT]]: ... +def POINTER(type: type[_CT]) -> type[pointer[_CT]]: ... # The real ctypes.pointer is a function, not a class. The stub version of pointer behaves like # ctypes._Pointer in that it is the base class for all pointer types. Unlike the real _Pointer, # it can be instantiated directly (to mimic the behavior of the real pointer function). class pointer(Generic[_CT], _PointerLike, _CData): - _type_: Type[_CT] + _type_: type[_CT] contents: _CT def __init__(self, arg: _CT = ...) -> None: ... @overload @@ -191,7 +190,7 @@ def set_errno(value: int) -> int: ... if sys.platform == "win32": def set_last_error(value: int) -> int: ... -def sizeof(obj_or_type: _CData | Type[_CData]) -> int: ... +def sizeof(obj_or_type: _CData | type[_CData]) -> int: ... def string_at(address: _CVoidConstPLike, size: int = ...) -> bytes: ... if sys.platform == "win32": @@ -252,7 +251,7 @@ class _CField: size: int class _StructUnionMeta(_CDataMeta): - _fields_: Sequence[tuple[str, Type[_CData]] | tuple[str, Type[_CData], int]] + _fields_: Sequence[tuple[str, type[_CData]] | tuple[str, type[_CData], int]] _pack_: int _anonymous_: Sequence[str] def __getattr__(self, name: str) -> _CField: ... @@ -275,9 +274,9 @@ class Array(Generic[_CT], _CData): def _length_(self, value: int) -> None: ... @property @abstractmethod - def _type_(self) -> Type[_CT]: ... + def _type_(self) -> type[_CT]: ... @_type_.setter - def _type_(self, value: Type[_CT]) -> None: ... + def _type_(self, value: type[_CT]) -> None: ... raw: bytes # Note: only available if _CT == c_char value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise # TODO These methods cannot be annotated correctly at the moment. diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 885facb9c..0678bd384 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -1,6 +1,7 @@ import sys import types -from typing import Any, Callable, Generic, Iterable, Mapping, Protocol, Type, TypeVar, overload +from builtins import type as Type # alias to avoid name clashes with fields named "type" +from typing import Any, Callable, Generic, Iterable, Mapping, Protocol, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -26,9 +27,9 @@ def astuple(obj: Any, *, tuple_factory: Callable[[list[Any]], _T]) -> _T: ... if sys.version_info >= (3, 10): @overload - def dataclass(__cls: Type[_T]) -> Type[_T]: ... + def dataclass(__cls: type[_T]) -> type[_T]: ... @overload - def dataclass(__cls: None) -> Callable[[Type[_T]], Type[_T]]: ... + def dataclass(__cls: None) -> Callable[[type[_T]], type[_T]]: ... @overload def dataclass( *, @@ -41,28 +42,28 @@ if sys.version_info >= (3, 10): match_args: bool = ..., kw_only: bool = ..., slots: bool = ..., - ) -> Callable[[Type[_T]], Type[_T]]: ... + ) -> Callable[[type[_T]], type[_T]]: ... elif sys.version_info >= (3, 8): # cls argument is now positional-only @overload - def dataclass(__cls: Type[_T]) -> Type[_T]: ... + def dataclass(__cls: type[_T]) -> type[_T]: ... @overload - def dataclass(__cls: None) -> Callable[[Type[_T]], Type[_T]]: ... + def dataclass(__cls: None) -> Callable[[type[_T]], type[_T]]: ... @overload def dataclass( *, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ... - ) -> Callable[[Type[_T]], Type[_T]]: ... + ) -> Callable[[type[_T]], type[_T]]: ... else: @overload - def dataclass(_cls: Type[_T]) -> Type[_T]: ... + def dataclass(_cls: type[_T]) -> type[_T]: ... @overload - def dataclass(_cls: None) -> Callable[[Type[_T]], Type[_T]]: ... + def dataclass(_cls: None) -> Callable[[type[_T]], type[_T]]: ... @overload def dataclass( *, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ... - ) -> Callable[[Type[_T]], Type[_T]]: ... + ) -> Callable[[type[_T]], type[_T]]: ... # See https://github.com/python/mypy/issues/10750 class _DefaultFactory(Protocol[_T_co]): diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index e0ce085c2..6400fb0e6 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -1,6 +1,6 @@ import sys from time import struct_time -from typing import ClassVar, NamedTuple, NoReturn, SupportsAbs, Type, TypeVar, overload +from typing import ClassVar, NamedTuple, NoReturn, SupportsAbs, TypeVar, overload from typing_extensions import final _S = TypeVar("_S") @@ -36,19 +36,19 @@ class date: min: ClassVar[date] max: ClassVar[date] resolution: ClassVar[timedelta] - def __new__(cls: Type[_S], year: int, month: int, day: int) -> _S: ... + def __new__(cls: type[_S], year: int, month: int, day: int) -> _S: ... @classmethod - def fromtimestamp(cls: Type[_S], __timestamp: float) -> _S: ... + def fromtimestamp(cls: type[_S], __timestamp: float) -> _S: ... @classmethod - def today(cls: Type[_S]) -> _S: ... + def today(cls: type[_S]) -> _S: ... @classmethod - def fromordinal(cls: Type[_S], __n: int) -> _S: ... + def fromordinal(cls: type[_S], __n: int) -> _S: ... if sys.version_info >= (3, 7): @classmethod - def fromisoformat(cls: Type[_S], __date_string: str) -> _S: ... + def fromisoformat(cls: type[_S], __date_string: str) -> _S: ... if sys.version_info >= (3, 8): @classmethod - def fromisocalendar(cls: Type[_S], year: int, week: int, day: int) -> _S: ... + def fromisocalendar(cls: type[_S], year: int, week: int, day: int) -> _S: ... @property def year(self) -> int: ... @property @@ -98,7 +98,7 @@ class time: max: ClassVar[time] resolution: ClassVar[timedelta] def __new__( - cls: Type[_S], + cls: type[_S], hour: int = ..., minute: int = ..., second: int = ..., @@ -127,7 +127,7 @@ class time: def isoformat(self, timespec: str = ...) -> str: ... if sys.version_info >= (3, 7): @classmethod - def fromisoformat(cls: Type[_S], __time_string: str) -> _S: ... + def fromisoformat(cls: type[_S], __time_string: str) -> _S: ... def strftime(self, __format: str) -> str: ... def __format__(self, __fmt: str) -> str: ... def utcoffset(self) -> timedelta | None: ... @@ -152,7 +152,7 @@ class timedelta(SupportsAbs[timedelta]): max: ClassVar[timedelta] resolution: ClassVar[timedelta] def __new__( - cls: Type[_S], + cls: type[_S], days: float = ..., seconds: float = ..., microseconds: float = ..., @@ -199,7 +199,7 @@ class datetime(date): max: ClassVar[datetime] resolution: ClassVar[timedelta] def __new__( - cls: Type[_S], + cls: type[_S], year: int, month: int, day: int, @@ -227,26 +227,26 @@ class datetime(date): # but it is named "timestamp" in the C implementation and "t" in the Python implementation, # so it is only truly *safe* to pass it as a positional argument. @classmethod - def fromtimestamp(cls: Type[_S], __timestamp: float, tz: _tzinfo | None = ...) -> _S: ... + def fromtimestamp(cls: type[_S], __timestamp: float, tz: _tzinfo | None = ...) -> _S: ... @classmethod - def utcfromtimestamp(cls: Type[_S], __t: float) -> _S: ... + def utcfromtimestamp(cls: type[_S], __t: float) -> _S: ... if sys.version_info >= (3, 8): @classmethod - def now(cls: Type[_S], tz: _tzinfo | None = ...) -> _S: ... + def now(cls: type[_S], tz: _tzinfo | None = ...) -> _S: ... else: @overload @classmethod - def now(cls: Type[_S], tz: None = ...) -> _S: ... + def now(cls: type[_S], tz: None = ...) -> _S: ... @overload @classmethod def now(cls, tz: _tzinfo) -> datetime: ... @classmethod - def utcnow(cls: Type[_S]) -> _S: ... + def utcnow(cls: type[_S]) -> _S: ... @classmethod def combine(cls, date: _date, time: _time, tzinfo: _tzinfo | None = ...) -> datetime: ... if sys.version_info >= (3, 7): @classmethod - def fromisoformat(cls: Type[_S], __date_string: str) -> _S: ... + def fromisoformat(cls: type[_S], __date_string: str) -> _S: ... def timestamp(self) -> float: ... def utctimetuple(self) -> struct_time: ... def date(self) -> _date: ... diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index 5ecacd91b..7947e6e20 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Iterator, MutableMapping, Type, Union +from typing import Iterator, MutableMapping, Union from typing_extensions import Literal _KeyType = Union[str, bytes] @@ -82,12 +82,12 @@ class _Database(MutableMapping[_KeyType, bytes]): 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: ... class _error(Exception): ... -error: tuple[Type[_error], Type[OSError]] +error: tuple[type[_error], type[OSError]] def whichdb(filename: str) -> str: ... def open(file: str, flag: _TFlags = ..., mode: int = ...) -> _Database: ... diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index 0a941b070..e040f23ce 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Iterator, MutableMapping, Type, Union +from typing import Iterator, MutableMapping, Union _KeyType = Union[str, bytes] _ValueType = Union[str, bytes] @@ -20,7 +20,7 @@ class _Database(MutableMapping[_KeyType, bytes]): 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 open(file: str, flag: str = ..., mode: int = ...) -> _Database: ... diff --git a/stdlib/dbm/gnu.pyi b/stdlib/dbm/gnu.pyi index 702f62d11..ef4706b97 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Type, TypeVar, Union, overload +from typing import TypeVar, Union, overload _T = TypeVar("_T") _KeyType = Union[str, bytes] @@ -24,7 +24,7 @@ class _gdbm: def __len__(self) -> int: ... 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: ... @overload def get(self, k: _KeyType) -> bytes | None: ... diff --git a/stdlib/dbm/ndbm.pyi b/stdlib/dbm/ndbm.pyi index 7b04c5385..c49ad82c5 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Type, TypeVar, Union, overload +from typing import TypeVar, Union, overload _T = TypeVar("_T") _KeyType = Union[str, bytes] @@ -20,7 +20,7 @@ class _dbm: 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: ... @overload def get(self, k: _KeyType) -> bytes | None: ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 07f9ca1bf..1bb81ab20 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -1,7 +1,7 @@ import numbers import sys from types import TracebackType -from typing import Any, Container, NamedTuple, Sequence, Type, TypeVar, Union, overload +from typing import Any, Container, NamedTuple, Sequence, TypeVar, Union, overload _Decimal = Union[Decimal, int] _DecimalNew = Union[Decimal, float, str, tuple[int, Sequence[int], int]] @@ -50,7 +50,7 @@ def getcontext() -> Context: ... def localcontext(ctx: Context | None = ...) -> _ContextManager: ... class Decimal: - def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Context | None = ...) -> _DecimalT: ... + def __new__(cls: type[_DecimalT], value: _DecimalNew = ..., context: Context | None = ...) -> _DecimalT: ... @classmethod def from_float(cls, __f: float) -> Decimal: ... def __bool__(self) -> bool: ... @@ -146,7 +146,7 @@ class Decimal: def rotate(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def scaleb(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def shift(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... - def __reduce__(self) -> tuple[Type[Decimal], tuple[str]]: ... + def __reduce__(self) -> tuple[type[Decimal], tuple[str]]: ... def __copy__(self) -> Decimal: ... def __deepcopy__(self, __memo: Any) -> Decimal: ... def __format__(self, __specifier: str, __context: Context | None = ...) -> str: ... @@ -156,9 +156,9 @@ class _ContextManager: saved_context: Context def __init__(self, new_context: Context) -> None: ... def __enter__(self) -> Context: ... - def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... + def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... -_TrapType = Type[DecimalException] +_TrapType = type[DecimalException] class Context: prec: int @@ -184,7 +184,7 @@ class Context: # __setattr__() only allows to set a specific set of attributes, # already defined above. def __delattr__(self, __name: str) -> None: ... - def __reduce__(self) -> tuple[Type[Context], tuple[Any, ...]]: ... + def __reduce__(self) -> tuple[type[Context], tuple[Any, ...]]: ... def clear_flags(self) -> None: ... def clear_traps(self) -> None: ... def copy(self) -> Context: ... diff --git a/stdlib/distutils/core.pyi b/stdlib/distutils/core.pyi index fc4cd81c4..6564c9a86 100644 --- a/stdlib/distutils/core.pyi +++ b/stdlib/distutils/core.pyi @@ -1,7 +1,7 @@ from distutils.cmd import Command as Command from distutils.dist import Distribution as Distribution from distutils.extension import Extension as Extension -from typing import Any, Mapping, Type +from typing import Any, Mapping def setup( *, @@ -20,14 +20,14 @@ def setup( scripts: list[str] = ..., ext_modules: list[Extension] = ..., classifiers: list[str] = ..., - distclass: Type[Distribution] = ..., + distclass: type[Distribution] = ..., script_name: str = ..., script_args: list[str] = ..., options: Mapping[str, Any] = ..., license: str = ..., keywords: list[str] | str = ..., platforms: list[str] | str = ..., - cmdclass: Mapping[str, Type[Command]] = ..., + cmdclass: Mapping[str, type[Command]] = ..., data_files: list[tuple[str, list[str]]] = ..., package_dir: Mapping[str, str] = ..., obsoletes: list[str] = ..., diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 5bb04b049..c5b3afe7c 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -1,6 +1,6 @@ from _typeshed import StrOrBytesPath, SupportsWrite from distutils.cmd import Command -from typing import IO, Any, Iterable, Mapping, Type +from typing import IO, Any, Iterable, Mapping class DistributionMetadata: def __init__(self, path: int | StrOrBytesPath | None = ...) -> None: ... @@ -50,7 +50,7 @@ class DistributionMetadata: def set_obsoletes(self, value: Iterable[str]) -> None: ... class Distribution: - cmdclass: dict[str, Type[Command]] + cmdclass: dict[str, type[Command]] metadata: DistributionMetadata def __init__(self, attrs: Mapping[str, Any] | None = ...) -> None: ... def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 611137740..31765ae4f 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -1,6 +1,6 @@ import types import unittest -from typing import Any, Callable, NamedTuple, Type +from typing import Any, Callable, NamedTuple class TestResults(NamedTuple): failed: int @@ -86,7 +86,7 @@ class DocTestFinder: ) -> list[DocTest]: ... _Out = Callable[[str], Any] -_ExcInfo = tuple[Type[BaseException], BaseException, types.TracebackType] +_ExcInfo = tuple[type[BaseException], BaseException, types.TracebackType] class DocTestRunner: DIVIDER: str diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index ddb9d9e45..b1389d11e 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -1,7 +1,7 @@ import sys from email.errors import HeaderParseError, MessageDefect from email.policy import Policy -from typing import Any, Iterable, Iterator, Pattern, Type, TypeVar, Union +from typing import Any, Iterable, Iterator, Pattern, TypeVar, Union from typing_extensions import Final _T = TypeVar("_T") @@ -327,7 +327,7 @@ class Terminal(str): syntactic_break: bool token_type: str defects: list[MessageDefect] - def __new__(cls: Type[_T], value: str, token_type: str) -> _T: ... + def __new__(cls: type[_T], value: str, token_type: str) -> _T: ... def pprint(self) -> None: ... @property def all_defects(self) -> list[MessageDefect]: ... diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index abf10ed4a..962571eb7 100644 --- a/stdlib/email/headerregistry.pyi +++ b/stdlib/email/headerregistry.pyi @@ -13,7 +13,7 @@ from email._header_value_parser import ( ) from email.errors import MessageDefect from email.policy import Policy -from typing import Any, ClassVar, Type +from typing import Any, ClassVar from typing_extensions import Literal class BaseHeader(str): @@ -141,10 +141,10 @@ if sys.version_info >= (3, 8): class HeaderRegistry: def __init__( - self, base_class: Type[BaseHeader] = ..., default_class: Type[BaseHeader] = ..., use_default_map: bool = ... + self, base_class: type[BaseHeader] = ..., default_class: type[BaseHeader] = ..., use_default_map: bool = ... ) -> None: ... - def map_to_type(self, name: str, cls: Type[BaseHeader]) -> None: ... - def __getitem__(self, name: str) -> Type[BaseHeader]: ... + def map_to_type(self, name: str, cls: type[BaseHeader]) -> None: ... + def __getitem__(self, name: str) -> type[BaseHeader]: ... def __call__(self, name: str, value: Any) -> BaseHeader: ... class Address: diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index a80a022ad..49f7bda4e 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -3,10 +3,10 @@ import types from abc import ABCMeta from builtins import property as _builtins_property from collections.abc import Iterable, Iterator, Mapping -from typing import Any, Type, TypeVar, Union, overload +from typing import Any, TypeVar, Union, overload _T = TypeVar("_T") -_S = TypeVar("_S", bound=Type[Enum]) +_S = TypeVar("_S", bound=type[Enum]) # The following all work: # >>> from enum import Enum @@ -32,7 +32,7 @@ class _EnumDict(dict[str, Any]): class EnumMeta(ABCMeta): if sys.version_info >= (3, 11): def __new__( - metacls: Type[_T], + metacls: type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict, @@ -42,20 +42,20 @@ class EnumMeta(ABCMeta): **kwds: Any, ) -> _T: ... elif sys.version_info >= (3, 9): - def __new__(metacls: Type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> _T: ... # type: ignore + def __new__(metacls: type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> _T: ... # type: ignore else: - def __new__(metacls: Type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> _T: ... # type: ignore - def __iter__(self: Type[_T]) -> Iterator[_T]: ... - def __reversed__(self: Type[_T]) -> Iterator[_T]: ... - def __contains__(self: Type[Any], member: object) -> bool: ... - def __getitem__(self: Type[_T], name: str) -> _T: ... + def __new__(metacls: type[_T], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> _T: ... # type: ignore + def __iter__(self: type[_T]) -> Iterator[_T]: ... + def __reversed__(self: type[_T]) -> Iterator[_T]: ... + def __contains__(self: type[Any], member: object) -> bool: ... + def __getitem__(self: type[_T], name: str) -> _T: ... @_builtins_property - def __members__(self: Type[_T]) -> types.MappingProxyType[str, _T]: ... + def __members__(self: type[_T]) -> types.MappingProxyType[str, _T]: ... def __len__(self) -> int: ... if sys.version_info >= (3, 11): # Simple value lookup @overload # type: ignore[override] - def __call__(cls: Type[_T], value: Any, names: None = ...) -> _T: ... + def __call__(cls: type[_T], value: Any, names: None = ...) -> _T: ... # Functional Enum API @overload def __call__( @@ -68,10 +68,10 @@ class EnumMeta(ABCMeta): type: type | None = ..., start: int = ..., boundary: FlagBoundary | None = ..., - ) -> Type[Enum]: ... + ) -> type[Enum]: ... else: @overload # type: ignore[override] - def __call__(cls: Type[_T], value: Any, names: None = ...) -> _T: ... + def __call__(cls: type[_T], value: Any, names: None = ...) -> _T: ... @overload def __call__( cls, @@ -82,7 +82,7 @@ class EnumMeta(ABCMeta): qualname: str | None = ..., type: type | None = ..., start: int = ..., - ) -> Type[Enum]: ... + ) -> type[Enum]: ... _member_names_: list[str] # undocumented _member_map_: dict[str, Enum] # undocumented _value2member_map_: dict[Any, Enum] # undocumented @@ -112,7 +112,7 @@ class Enum(metaclass=EnumMeta): def _missing_(cls, value: object) -> Any: ... @staticmethod def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> Any: ... - def __new__(cls: Type[_T], value: object) -> _T: ... + def __new__(cls: type[_T], value: object) -> _T: ... def __repr__(self) -> str: ... def __str__(self) -> str: ... def __dir__(self) -> list[str]: ... @@ -128,7 +128,7 @@ class IntEnum(int, Enum): else: @types.DynamicClassAttribute def value(self) -> int: ... - def __new__(cls: Type[_T], value: int | _T) -> _T: ... + def __new__(cls: type[_T], value: int | _T) -> _T: ... def unique(enumeration: _S) -> _S: ... @@ -143,7 +143,7 @@ class auto(IntFlag): else: @types.DynamicClassAttribute def value(self) -> Any: ... - def __new__(cls: Type[_T]) -> _T: ... + def __new__(cls: type[_T]) -> _T: ... class Flag(Enum): _name_: str | None # type: ignore[assignment] @@ -168,7 +168,7 @@ class Flag(Enum): def __invert__(self: _T) -> _T: ... class IntFlag(int, Flag): - def __new__(cls: Type[_T], value: int | _T) -> _T: ... + def __new__(cls: type[_T], value: int | _T) -> _T: ... def __or__(self: _T, other: int | _T) -> _T: ... def __and__(self: _T, other: int | _T) -> _T: ... def __xor__(self: _T, other: int | _T) -> _T: ... @@ -178,7 +178,7 @@ class IntFlag(int, Flag): if sys.version_info >= (3, 11): class StrEnum(str, Enum): - def __new__(cls: Type[_T], value: str | _T) -> _T: ... + def __new__(cls: type[_T], value: str | _T) -> _T: ... _value_: str @property def value(self) -> str: ... @@ -192,7 +192,7 @@ if sys.version_info >= (3, 11): EJECT = FlagBoundary.EJECT KEEP = FlagBoundary.KEEP class property(types.DynamicClassAttribute): - def __set_name__(self, ownerclass: Type[Enum], name: str) -> None: ... + def __set_name__(self, ownerclass: type[Enum], name: str) -> None: ... name: str clsname: str def global_enum(cls: _S) -> _S: ... diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index 8de5ae209..9536e511e 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -1,7 +1,7 @@ import sys from decimal import Decimal from numbers import Integral, Rational, Real -from typing import Type, TypeVar, Union, overload +from typing import TypeVar, Union, overload from typing_extensions import Literal _ComparableNum = Union[int, float, Decimal, Real] @@ -20,10 +20,10 @@ if sys.version_info < (3, 9): class Fraction(Rational): @overload def __new__( - cls: Type[_T], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ... + cls: type[_T], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ... ) -> _T: ... @overload - def __new__(cls: Type[_T], __value: float | Decimal | str, *, _normalize: bool = ...) -> _T: ... + def __new__(cls: type[_T], __value: float | Decimal | str, *, _normalize: bool = ...) -> _T: ... @classmethod def from_float(cls, f: float) -> Fraction: ... @classmethod diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index f84199c16..62adf300e 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -3,7 +3,7 @@ from _typeshed import Self, SupportsRead, SupportsReadline from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Callable, Iterable, Iterator, TextIO, Type +from typing import Any, Callable, Iterable, Iterator, TextIO from typing_extensions import Literal MSG_OOB: int @@ -18,7 +18,7 @@ class error_temp(Error): ... class error_perm(Error): ... class error_proto(Error): ... -all_errors: tuple[Type[Exception], ...] +all_errors: tuple[type[Exception], ...] class FTP: debugging: int @@ -35,7 +35,7 @@ class FTP: encoding: str 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: ... source_address: tuple[str, int] | None if sys.version_info >= (3, 9): diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 9c56ff1d2..ff1c3fad6 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -1,7 +1,7 @@ import sys import types from _typeshed import SupportsAllComparisons, SupportsItems -from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, Type, TypeVar, overload +from typing import Any, Callable, Generic, Hashable, Iterable, NamedTuple, Sequence, Sized, TypeVar, overload from typing_extensions import final if sys.version_info >= (3, 9): @@ -44,14 +44,14 @@ WRAPPER_UPDATES: Sequence[str] def update_wrapper(wrapper: _T, wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> _T: ... def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_T], _T]: ... -def total_ordering(cls: Type[_T]) -> Type[_T]: ... +def total_ordering(cls: type[_T]) -> type[_T]: ... def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], SupportsAllComparisons]: ... class partial(Generic[_T]): func: Callable[..., _T] args: tuple[Any, ...] keywords: dict[str, Any] - def __new__(cls: Type[_S], __func: Callable[..., _T], *args: Any, **kwargs: Any) -> _S: ... + def __new__(cls: type[_S], __func: Callable[..., _T], *args: Any, **kwargs: Any) -> _S: ... def __call__(__self, *args: Any, **kwargs: Any) -> _T: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -67,7 +67,7 @@ class partialmethod(Generic[_T]): def __init__(self, __func: Callable[..., _T], *args: Any, **keywords: Any) -> None: ... @overload def __init__(self, __func: _Descriptor, *args: Any, **keywords: Any) -> None: ... - def __get__(self, obj: Any, cls: Type[Any]) -> Callable[..., _T]: ... + def __get__(self, obj: Any, cls: type[Any]) -> Callable[..., _T]: ... @property def __isabstractmethod__(self) -> bool: ... if sys.version_info >= (3, 9): @@ -79,14 +79,14 @@ class _SingleDispatchCallable(Generic[_T]): # @fun.register(complex) # def _(arg, verbose=False): ... @overload - def register(self, cls: Type[Any], func: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... + def register(self, cls: type[Any], func: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... # @fun.register # def _(arg: int, verbose=False): @overload def register(self, cls: Callable[..., _T], func: None = ...) -> Callable[..., _T]: ... # fun.register(int, lambda x: x) @overload - def register(self, cls: Type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ... + def register(self, cls: type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ... def _clear_cache(self) -> None: ... def __call__(__self, *args: Any, **kwargs: Any) -> _T: ... @@ -98,21 +98,21 @@ if sys.version_info >= (3, 8): func: Callable[..., _T] def __init__(self, func: Callable[..., _T]) -> None: ... @overload - def register(self, cls: Type[Any], method: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... + def register(self, cls: type[Any], method: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ... @overload def register(self, cls: Callable[..., _T], method: None = ...) -> Callable[..., _T]: ... @overload - def register(self, cls: Type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ... + def register(self, cls: type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ... def __call__(self, *args: Any, **kwargs: Any) -> _T: ... class cached_property(Generic[_T]): func: Callable[[Any], _T] attrname: str | None def __init__(self, func: Callable[[Any], _T]) -> None: ... @overload - def __get__(self, instance: None, owner: Type[Any] | None = ...) -> cached_property[_T]: ... + def __get__(self, instance: None, owner: type[Any] | None = ...) -> cached_property[_T]: ... @overload - def __get__(self, instance: object, owner: Type[Any] | None = ...) -> _T: ... - def __set_name__(self, owner: Type[Any], name: str) -> None: ... + def __get__(self, instance: object, owner: type[Any] | None = ...) -> _T: ... + def __set_name__(self, owner: type[Any], name: str) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index 21be9fb1f..27a5e442d 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath -from typing import IO, Any, Container, Iterable, Sequence, Type, TypeVar, overload +from typing import IO, Any, Container, Iterable, Sequence, TypeVar, overload from typing_extensions import Literal class NullTranslations: @@ -45,7 +45,7 @@ if sys.version_info >= (3, 11): domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., - class_: Type[_T] = ..., + class_: type[_T] = ..., fallback: Literal[False] = ..., ) -> _T: ... @overload @@ -53,7 +53,7 @@ if sys.version_info >= (3, 11): domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., - class_: Type[Any] = ..., + class_: type[Any] = ..., fallback: Literal[True] = ..., ) -> Any: ... def install(domain: str, localedir: StrPath | None = ..., names: Container[str] | None = ...) -> None: ... @@ -73,7 +73,7 @@ else: domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., - class_: Type[_T] = ..., + class_: type[_T] = ..., fallback: Literal[False] = ..., codeset: str | None = ..., ) -> _T: ... @@ -82,7 +82,7 @@ else: domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., - class_: Type[Any] = ..., + class_: type[Any] = ..., fallback: Literal[True] = ..., codeset: str | None = ..., ) -> Any: ... diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index a8d32e328..158a04c21 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -5,7 +5,7 @@ import sys import types from _typeshed import Self, WriteableBuffer from socket import socket -from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, Mapping, Protocol, Type, TypeVar, Union, overload +from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, Mapping, Protocol, TypeVar, Union, overload _DataType = Union[bytes, IO[Any], Iterable[bytes], str] _T = TypeVar("_T") @@ -107,7 +107,7 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): # type: ignore # argument disp def __iter__(self) -> Iterator[bytes]: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> bool | None: ... def info(self) -> email.message.Message: ... def geturl(self) -> str: ... @@ -135,7 +135,7 @@ class HTTPConnection: auto_open: int # undocumented debuglevel: int default_port: int # undocumented - response_class: Type[HTTPResponse] # undocumented + response_class: type[HTTPResponse] # undocumented timeout: float | None host: str port: int diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 1b2774d8f..33b99239e 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -5,7 +5,7 @@ from _typeshed import Self from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any, Callable, Pattern, Type, Union +from typing import IO, Any, Callable, Pattern, Union from typing_extensions import Literal # TODO: Commands should use their actual return types, not this type alias. @@ -17,9 +17,9 @@ _AnyResponseData = Union[list[None], list[Union[bytes, tuple[bytes, bytes]]]] _list = list # conflicts with a method named "list" class IMAP4: - error: Type[Exception] - abort: Type[Exception] - readonly: Type[Exception] + error: type[Exception] + abort: type[Exception] + readonly: type[Exception] mustquote: Pattern[str] debug: int state: str @@ -63,7 +63,7 @@ class IMAP4: def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... def enable(self, capability: str) -> _CommandResults: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... + def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... def expunge(self) -> _CommandResults: ... def fetch(self, message_set: str, message_parts: str) -> tuple[str, _AnyResponseData]: ... def getacl(self, mailbox: str) -> _CommandResults: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index a96e30865..26ea5baca 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -23,7 +23,7 @@ from types import ( if sys.version_info >= (3, 7): from types import ClassMethodDescriptorType, WrapperDescriptorType, MemberDescriptorType, MethodDescriptorType -from typing import Any, ClassVar, Coroutine, NamedTuple, Protocol, Type, TypeVar, Union +from typing import Any, ClassVar, Coroutine, NamedTuple, Protocol, TypeVar, Union from typing_extensions import Literal, TypeGuard # @@ -58,7 +58,7 @@ modulesbyfile: dict[str, Any] def getmembers(object: object, predicate: Callable[[Any], bool] | None = ...) -> list[tuple[str, Any]]: ... def getmodulename(path: str) -> str | None: ... def ismodule(object: object) -> TypeGuard[ModuleType]: ... -def isclass(object: object) -> TypeGuard[Type[Any]]: ... +def isclass(object: object) -> TypeGuard[type[Any]]: ... def ismethod(object: object) -> TypeGuard[MethodType]: ... def isfunction(object: object) -> TypeGuard[FunctionType]: ... @@ -125,7 +125,7 @@ def isdatadescriptor(object: object) -> TypeGuard[_SupportsSet[Any, Any] | _Supp # # Retrieving source code # -_SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]] +_SourceObjectType = Union[ModuleType, type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]] def findsource(object: _SourceObjectType) -> tuple[list[str], int]: ... def getabsfile(object: _SourceObjectType, _filename: str | None = ...) -> str: ... @@ -172,7 +172,7 @@ class Signature: def bind(self, *args: Any, **kwargs: Any) -> BoundArguments: ... def bind_partial(self, *args: Any, **kwargs: Any) -> BoundArguments: ... def replace( - self: Self, *, parameters: Sequence[Parameter] | Type[_void] | None = ..., return_annotation: Any = ... + self: Self, *, parameters: Sequence[Parameter] | type[_void] | None = ..., return_annotation: Any = ... ) -> Self: ... if sys.version_info >= (3, 10): @classmethod @@ -191,7 +191,7 @@ class Signature: if sys.version_info >= (3, 10): def get_annotations( - obj: Callable[..., Any] | Type[Any] | ModuleType, + obj: Callable[..., Any] | type[Any] | ModuleType, *, globals: Mapping[str, Any] | None = ..., locals: Mapping[str, Any] | None = ..., @@ -230,8 +230,8 @@ class Parameter: def replace( self: Self, *, - name: str | Type[_void] = ..., - kind: _ParameterKind | Type[_void] = ..., + name: str | type[_void] = ..., + kind: _ParameterKind | type[_void] = ..., default: Any = ..., annotation: Any = ..., ) -> Self: ... @@ -252,7 +252,7 @@ class BoundArguments: # seem to be supporting this at the moment: # _ClassTreeItem = list[_ClassTreeItem] | Tuple[type, Tuple[type, ...]] def getclasstree(classes: list[type], unique: bool = ...) -> list[Any]: ... -def walktree(classes: list[type], children: dict[Type[Any], list[type]], parent: Type[Any] | None) -> list[Any]: ... +def walktree(classes: list[type], children: dict[type[Any], list[type]], parent: type[Any] | None) -> list[Any]: ... class Arguments(NamedTuple): args: list[str] diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 12abe0673..19f495e88 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -4,7 +4,7 @@ import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer from os import _Opener from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, TextIO, Type +from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, TextIO DEFAULT_BUFFER_SIZE: int @@ -26,7 +26,7 @@ class IOBase: def __next__(self) -> bytes: ... 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 ) -> bool | None: ... def close(self) -> None: ... def fileno(self) -> int: ... diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index a5a7f4f1b..30b589770 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -9,7 +9,6 @@ from typing import ( SupportsComplex, SupportsFloat, SupportsInt, - Type, TypeVar, Union, overload, @@ -68,7 +67,7 @@ class chain(Iterator[_T], Generic[_T]): def __iter__(self) -> Iterator[_T]: ... @classmethod # We use Type and not Type[_S] to not lose the type inference from __iterable - def from_iterable(cls: Type[Any], __iterable: Iterable[Iterable[_S]]) -> Iterator[_S]: ... + def from_iterable(cls: type[Any], __iterable: Iterable[Iterable[_S]]) -> Iterator[_S]: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, __item: Any) -> GenericAlias: ... diff --git a/stdlib/json/__init__.pyi b/stdlib/json/__init__.pyi index 3e26d1b14..b9867b55f 100644 --- a/stdlib/json/__init__.pyi +++ b/stdlib/json/__init__.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsRead -from typing import IO, Any, Callable, Type +from typing import IO, Any, Callable from .decoder import JSONDecodeError as JSONDecodeError, JSONDecoder as JSONDecoder from .encoder import JSONEncoder as JSONEncoder @@ -11,7 +11,7 @@ def dumps( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Type[JSONEncoder] | None = ..., + cls: type[JSONEncoder] | None = ..., indent: None | int | str = ..., separators: tuple[str, str] | None = ..., default: Callable[[Any], Any] | None = ..., @@ -26,7 +26,7 @@ def dump( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Type[JSONEncoder] | None = ..., + cls: type[JSONEncoder] | None = ..., indent: None | int | str = ..., separators: tuple[str, str] | None = ..., default: Callable[[Any], Any] | None = ..., @@ -36,7 +36,7 @@ def dump( def loads( s: str | bytes, *, - cls: Type[JSONDecoder] | None = ..., + cls: type[JSONDecoder] | None = ..., object_hook: Callable[[dict[Any, Any]], Any] | None = ..., parse_float: Callable[[str], Any] | None = ..., parse_int: Callable[[str], Any] | None = ..., @@ -47,7 +47,7 @@ def loads( def load( fp: SupportsRead[str | bytes], *, - cls: Type[JSONDecoder] | None = ..., + cls: type[JSONDecoder] | None = ..., object_hook: Callable[[dict[Any, Any]], Any] | None = ..., parse_float: Callable[[str], Any] | None = ..., parse_int: Callable[[str], Any] | None = ..., diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index d0d50041a..08a785eb4 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -6,10 +6,10 @@ from io import TextIOWrapper from string import Template from time import struct_time from types import FrameType, TracebackType -from typing import Any, ClassVar, Generic, Optional, Pattern, TextIO, Type, TypeVar, Union, overload +from typing import Any, ClassVar, Generic, Optional, Pattern, TextIO, TypeVar, Union, overload from typing_extensions import Literal -_SysExcInfoType = Union[tuple[Type[BaseException], BaseException, Optional[TracebackType]], tuple[None, None, None]] +_SysExcInfoType = Union[tuple[type[BaseException], BaseException, Optional[TracebackType]], tuple[None, None, None]] _ExcInfoType = Union[None, bool, _SysExcInfoType, BaseException] _ArgsType = Union[tuple[object, ...], Mapping[str, object]] _FilterType = Union[Filter, Callable[[LogRecord], int]] @@ -39,11 +39,11 @@ class Manager: # undocumented disable: int emittedNoHandlerWarning: bool loggerDict: dict[str, Logger | PlaceHolder] - loggerClass: Type[Logger] | None + loggerClass: type[Logger] | None logRecordFactory: Callable[..., LogRecord] | None def __init__(self, rootnode: RootLogger) -> None: ... def getLogger(self, name: str) -> Logger: ... - def setLoggerClass(self, klass: Type[Logger]) -> None: ... + def setLoggerClass(self, klass: type[Logger]) -> None: ... def setLogRecordFactory(self, factory: Callable[..., LogRecord]) -> None: ... class Logger(Filterer): @@ -546,7 +546,7 @@ class LoggerAdapter(Generic[_L]): def name(self) -> str: ... # undocumented def getLogger(name: str | None = ...) -> Logger: ... -def getLoggerClass() -> Type[Logger]: ... +def getLoggerClass() -> type[Logger]: ... def getLogRecordFactory() -> Callable[..., LogRecord]: ... if sys.version_info >= (3, 8): @@ -703,7 +703,7 @@ else: ) -> None: ... def shutdown(handlerList: Sequence[Any] = ...) -> None: ... # handlerList is undocumented -def setLoggerClass(klass: Type[Logger]) -> None: ... +def setLoggerClass(klass: type[Logger]) -> None: ... def captureWarnings(capture: bool) -> None: ... def setLogRecordFactory(factory: Callable[..., LogRecord]) -> None: ... diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index ffd9c3005..4ce792300 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -2,22 +2,7 @@ import email.message import sys from _typeshed import Self, StrOrBytesPath from types import TracebackType -from typing import ( - IO, - Any, - AnyStr, - Callable, - Generic, - Iterable, - Iterator, - Mapping, - Protocol, - Sequence, - Type, - TypeVar, - Union, - overload, -) +from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Mapping, Protocol, Sequence, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -184,7 +169,7 @@ class _ProxyFile(Generic[AnyStr]): def seek(self, offset: int, whence: int = ...) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ... + def __exit__(self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... def seekable(self) -> bool: ... diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index b5866492a..5933433ac 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -1,6 +1,6 @@ import sys from types import ModuleType -from typing import Any, Container, Iterable, Sequence, Type +from typing import Any, Container, Iterable, Sequence from typing_extensions import Literal if sys.platform == "win32": @@ -34,8 +34,8 @@ if sys.platform == "win32": def change_sequence( seq: Sequence[tuple[str, str | None, int]], action: str, - seqno: int | Type[_Unspecified] = ..., - cond: str | Type[_Unspecified] = ..., + seqno: int | type[_Unspecified] = ..., + cond: str | type[_Unspecified] = ..., ) -> None: ... def add_data(db: _Database, table: str, values: Iterable[tuple[Any, ...]]) -> None: ... def add_stream(db: _Database, name: str, path: str) -> None: ... diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index 56db4594e..40630d66f 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -2,7 +2,7 @@ import socket import sys import types from _typeshed import Self -from typing import Any, Iterable, Type, Union +from typing import Any, Iterable, Union if sys.version_info >= (3, 8): from typing import SupportsIndex @@ -31,7 +31,7 @@ class _ConnectionBase: def poll(self, timeout: float | None = ...) -> bool: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... class Connection(_ConnectionBase): ... @@ -51,7 +51,7 @@ class Listener: def last_accepted(self) -> _Address | None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... def deliver_challenge(connection: Connection, authkey: bytes) -> None: ... diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index 83e1b7884..4f4470c97 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -8,7 +8,7 @@ from multiprocessing import queues, synchronize from multiprocessing.pool import Pool as _Pool from multiprocessing.process import BaseProcess from multiprocessing.sharedctypes import SynchronizedArray, SynchronizedBase -from typing import Any, Type, TypeVar, Union, overload +from typing import Any, TypeVar, Union, overload from typing_extensions import Literal _LockLike = Union[synchronize.Lock, synchronize.RLock] @@ -20,11 +20,11 @@ class TimeoutError(ProcessError): ... class AuthenticationError(ProcessError): ... class BaseContext: - Process: Type[BaseProcess] - ProcessError: Type[Exception] - BufferTooShort: Type[Exception] - TimeoutError: Type[Exception] - AuthenticationError: Type[Exception] + Process: type[BaseProcess] + ProcessError: type[Exception] + BufferTooShort: type[Exception] + TimeoutError: type[Exception] + AuthenticationError: type[Exception] # N.B. The methods below are applied at runtime to generate # multiprocessing.*, so the signatures should be identical (modulo self). @@ -60,26 +60,26 @@ class BaseContext: maxtasksperchild: int | None = ..., ) -> _Pool: ... @overload - def RawValue(self, typecode_or_type: Type[_CT], *args: Any) -> _CT: ... + def RawValue(self, typecode_or_type: type[_CT], *args: Any) -> _CT: ... @overload def RawValue(self, typecode_or_type: str, *args: Any) -> Any: ... @overload - def RawArray(self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ... + def RawArray(self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ... @overload def RawArray(self, typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ... @overload - def Value(self, typecode_or_type: Type[_CT], *args: Any, lock: Literal[False]) -> _CT: ... + def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[False]) -> _CT: ... @overload - def Value(self, typecode_or_type: Type[_CT], *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[_CT]: ... + def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[_CT]: ... @overload def Value(self, typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike) -> SynchronizedBase[Any]: ... @overload - def Value(self, typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ...) -> Any: ... + def Value(self, typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = ...) -> Any: ... @overload - def Array(self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]) -> _CT: ... + def Array(self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]) -> _CT: ... @overload def Array( - self, typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike + self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike ) -> SynchronizedArray[_CT]: ... @overload def Array( @@ -87,7 +87,7 @@ class BaseContext: ) -> SynchronizedArray[Any]: ... @overload def Array( - self, typecode_or_type: str | Type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = ... + self, typecode_or_type: str | type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = ... ) -> Any: ... def freeze_support(self) -> None: ... def get_logger(self) -> Logger: ... @@ -127,7 +127,7 @@ class Process(BaseProcess): def _Popen(process_obj: BaseProcess) -> DefaultContext: ... class DefaultContext(BaseContext): - Process: Type[multiprocessing.Process] + Process: type[multiprocessing.Process] def __init__(self, context: BaseContext) -> None: ... def set_start_method(self, method: str | None, force: bool = ...) -> None: ... def get_start_method(self, allow_none: bool = ...) -> str: ... @@ -150,13 +150,13 @@ if sys.platform != "win32": def _Popen(process_obj: BaseProcess) -> Any: ... class ForkContext(BaseContext): _name: str - Process: Type[ForkProcess] + Process: type[ForkProcess] class SpawnContext(BaseContext): _name: str - Process: Type[SpawnProcess] + Process: type[SpawnProcess] class ForkServerContext(BaseContext): _name: str - Process: Type[ForkServerProcess] + Process: type[ForkServerProcess] else: class SpawnProcess(BaseProcess): @@ -165,7 +165,7 @@ else: def _Popen(process_obj: BaseProcess) -> Any: ... class SpawnContext(BaseContext): _name: str - Process: Type[SpawnProcess] + Process: type[SpawnProcess] def _force_start_method(method: str) -> None: ... def get_spawning_popen() -> Any | None: ... diff --git a/stdlib/multiprocessing/dummy/connection.pyi b/stdlib/multiprocessing/dummy/connection.pyi index 9500a3836..26413cb75 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -1,7 +1,7 @@ from _typeshed import Self from queue import Queue from types import TracebackType -from typing import Any, Type, Union +from typing import Any, Union families: list[None] @@ -16,7 +16,7 @@ class Connection: send_bytes: Any 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 __init__(self, _in: Any, _out: Any) -> None: ... def close(self) -> None: ... @@ -28,7 +28,7 @@ class Listener: def address(self) -> Queue[Any] | 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 __init__(self, address: _Address | None = ..., family: int | None = ..., backlog: int = ...) -> None: ... def accept(self) -> Connection: ... diff --git a/stdlib/multiprocessing/sharedctypes.pyi b/stdlib/multiprocessing/sharedctypes.pyi index bd9d8f089..bbe3c1739 100644 --- a/stdlib/multiprocessing/sharedctypes.pyi +++ b/stdlib/multiprocessing/sharedctypes.pyi @@ -3,25 +3,25 @@ from collections.abc import Callable, Iterable, Sequence from ctypes import _CData, _SimpleCData, c_char from multiprocessing.context import BaseContext from multiprocessing.synchronize import _LockLike -from typing import Any, Generic, Protocol, Type, TypeVar, overload +from typing import Any, Generic, Protocol, TypeVar, overload from typing_extensions import Literal _T = TypeVar("_T") _CT = TypeVar("_CT", bound=_CData) @overload -def RawValue(typecode_or_type: Type[_CT], *args: Any) -> _CT: ... +def RawValue(typecode_or_type: type[_CT], *args: Any) -> _CT: ... @overload def RawValue(typecode_or_type: str, *args: Any) -> Any: ... @overload -def RawArray(typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ... +def RawArray(typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any]) -> ctypes.Array[_CT]: ... @overload def RawArray(typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ... @overload -def Value(typecode_or_type: Type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = ...) -> _CT: ... +def Value(typecode_or_type: type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = ...) -> _CT: ... @overload def Value( - typecode_or_type: Type[_CT], *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ... + typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike, ctx: BaseContext | None = ... ) -> SynchronizedBase[_CT]: ... @overload def Value( @@ -29,15 +29,15 @@ def Value( ) -> SynchronizedBase[Any]: ... @overload def Value( - typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: BaseContext | None = ... + typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: BaseContext | None = ... ) -> Any: ... @overload def Array( - typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False], ctx: BaseContext | None = ... + typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False], ctx: BaseContext | None = ... ) -> _CT: ... @overload def Array( - typecode_or_type: Type[_CT], + typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike, @@ -53,7 +53,7 @@ def Array( ) -> SynchronizedArray[Any]: ... @overload def Array( - typecode_or_type: str | Type[_CData], + typecode_or_type: str | type[_CData], size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = ..., diff --git a/stdlib/optparse.pyi b/stdlib/optparse.pyi index 416bc5446..c32a17ceb 100644 --- a/stdlib/optparse.pyi +++ b/stdlib/optparse.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, Sequence, Type, overload +from typing import IO, Any, AnyStr, Callable, Iterable, Mapping, Sequence, overload NO_DEFAULT: tuple[str, ...] SUPPRESS_HELP: str @@ -119,8 +119,8 @@ class OptionContainer: conflict_handler: str defaults: dict[str, Any] description: Any - option_class: Type[Option] - def __init__(self, option_class: Type[Option], conflict_handler: Any, description: Any) -> None: ... + option_class: type[Option] + def __init__(self, option_class: type[Option], conflict_handler: Any, description: Any) -> None: ... def _check_conflict(self, option: Any) -> None: ... def _create_option_mappings(self) -> None: ... def _share_option_mappings(self, parser: OptionParser) -> None: ... @@ -177,7 +177,7 @@ class OptionParser(OptionContainer): self, usage: str | None = ..., option_list: Iterable[Option] | None = ..., - option_class: Type[Option] = ..., + option_class: type[Option] = ..., version: str | None = ..., conflict_handler: str = ..., description: str | None = ..., diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index b541345c0..9db873287 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -11,7 +11,7 @@ from _typeshed import ( from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from os import PathLike, stat_result from types import TracebackType -from typing import IO, Any, BinaryIO, Generator, Sequence, Type, TypeVar, overload +from typing import IO, Any, BinaryIO, Generator, Sequence, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -28,7 +28,7 @@ class PurePath(PathLike[str]): suffix: str suffixes: list[str] stem: str - def __new__(cls: Type[_P], *args: StrPath) -> _P: ... + def __new__(cls: type[_P], *args: StrPath) -> _P: ... def __hash__(self) -> int: ... def __lt__(self, other: PurePath) -> bool: ... def __le__(self, other: PurePath) -> bool: ... @@ -61,13 +61,13 @@ class PurePosixPath(PurePath): ... class PureWindowsPath(PurePath): ... class Path(PurePath): - def __new__(cls: Type[_P], *args: StrPath, **kwargs: Any) -> _P: ... + def __new__(cls: type[_P], *args: StrPath, **kwargs: Any) -> _P: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... @classmethod - def cwd(cls: Type[_P]) -> _P: ... + def cwd(cls: type[_P]) -> _P: ... if sys.version_info >= (3, 10): def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ... def chmod(self, mode: int, *, follow_symlinks: bool = ...) -> None: ... @@ -166,7 +166,7 @@ class Path(PurePath): else: def unlink(self) -> None: ... @classmethod - def home(cls: Type[_P]) -> _P: ... + def home(cls: type[_P]) -> _P: ... def absolute(self: _P) -> _P: ... def expanduser(self: _P) -> _P: ... def read_bytes(self) -> bytes: ... diff --git a/stdlib/pickle.pyi b/stdlib/pickle.pyi index 46c349137..d165e6e28 100644 --- a/stdlib/pickle.pyi +++ b/stdlib/pickle.pyi @@ -1,11 +1,11 @@ import sys -from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Optional, Protocol, Type, Union +from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Optional, Protocol, Union from typing_extensions import final HIGHEST_PROTOCOL: int DEFAULT_PROTOCOL: int -bytes_types: tuple[Type[Any], ...] # undocumented +bytes_types: tuple[type[Any], ...] # undocumented class _ReadableFileobj(Protocol): def read(self, __n: int) -> bytes: ... diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index 04a695f5f..056d115f5 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -1,7 +1,7 @@ -from typing import IO, Any, Callable, Iterator, MutableMapping, Type +from typing import IO, Any, Callable, Iterator, MutableMapping _Reader = Callable[[IO[bytes]], Any] -bytes_types: tuple[Type[Any], ...] +bytes_types: tuple[type[Any], ...] UP_TO_NEWLINE: int TAKEN_FROM_ARGUMENT1: int @@ -108,9 +108,9 @@ long4: ArgumentDescriptor class StackObject: name: str - obtype: Type[Any] | tuple[Type[Any], ...] + obtype: type[Any] | tuple[type[Any], ...] doc: str - def __init__(self, name: str, obtype: Type[Any] | tuple[Type[Any], ...], doc: str) -> None: ... + def __init__(self, name: str, obtype: type[Any] | tuple[type[Any], ...], doc: str) -> None: ... pyint: StackObject pylong: StackObject diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index 7abe9dd29..6f8157fe5 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -1,7 +1,7 @@ import sys from datetime import datetime from enum import Enum -from typing import IO, Any, Mapping, MutableMapping, Type +from typing import IO, Any, Mapping, MutableMapping class PlistFormat(Enum): FMT_XML: int @@ -11,8 +11,8 @@ FMT_XML = PlistFormat.FMT_XML FMT_BINARY = PlistFormat.FMT_BINARY if sys.version_info >= (3, 9): - def load(fp: IO[bytes], *, fmt: PlistFormat | None = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... - def loads(value: bytes, *, fmt: PlistFormat | None = ..., dict_type: Type[MutableMapping[str, Any]] = ...) -> Any: ... + def load(fp: IO[bytes], *, fmt: PlistFormat | None = ..., dict_type: type[MutableMapping[str, Any]] = ...) -> Any: ... + def loads(value: bytes, *, fmt: PlistFormat | None = ..., dict_type: type[MutableMapping[str, Any]] = ...) -> Any: ... else: def load( @@ -20,14 +20,14 @@ else: *, fmt: PlistFormat | None = ..., use_builtin_types: bool = ..., - dict_type: Type[MutableMapping[str, Any]] = ..., + dict_type: type[MutableMapping[str, Any]] = ..., ) -> Any: ... def loads( value: bytes, *, fmt: PlistFormat | None = ..., use_builtin_types: bool = ..., - dict_type: Type[MutableMapping[str, Any]] = ..., + dict_type: type[MutableMapping[str, Any]] = ..., ) -> Any: ... def dump( diff --git a/stdlib/py_compile.pyi b/stdlib/py_compile.pyi index 1df818509..2c967c221 100644 --- a/stdlib/py_compile.pyi +++ b/stdlib/py_compile.pyi @@ -1,12 +1,12 @@ import sys -from typing import AnyStr, Type +from typing import AnyStr class PyCompileError(Exception): exc_type_name: str exc_value: BaseException file: str msg: str - def __init__(self, exc_type: Type[BaseException], exc_value: BaseException, file: str, msg: str = ...) -> None: ... + def __init__(self, exc_type: type[BaseException], exc_value: BaseException, file: str, msg: str = ...) -> None: ... if sys.version_info >= (3, 7): import enum diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index a1d4359d2..cc656f9b7 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -1,10 +1,10 @@ from _typeshed import SupportsWrite from reprlib import Repr from types import MethodType, ModuleType, TracebackType -from typing import IO, Any, AnyStr, Callable, Container, Mapping, MutableMapping, NoReturn, Optional, Type +from typing import IO, Any, AnyStr, Callable, Container, Mapping, MutableMapping, NoReturn, Optional # the return type of sys.exc_info(), used by ErrorDuringImport.__init__ -_Exc_Info = tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_Exc_Info = tuple[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]] __author__: str __date__: str @@ -28,7 +28,7 @@ def synopsis(filename: str, cache: MutableMapping[str, tuple[int, str]] = ...) - class ErrorDuringImport(Exception): filename: str - exc: Type[BaseException] | None + exc: type[BaseException] | None value: BaseException | None tb: TracebackType | None def __init__(self, filename: str, exc_info: _Exc_Info) -> None: ... diff --git a/stdlib/select.pyi b/stdlib/select.pyi index e57504b5b..3e5aec69f 100644 --- a/stdlib/select.pyi +++ b/stdlib/select.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptorLike, Self from types import TracebackType -from typing import Any, Iterable, Type +from typing import Any, Iterable if sys.platform != "win32": PIPE_BUF: int @@ -105,7 +105,7 @@ if sys.platform == "linux": def __enter__(self: Self) -> Self: ... def __exit__( self, - exc_type: Type[BaseException] | None = ..., + exc_type: type[BaseException] | None = ..., exc_val: BaseException | None = ..., exc_tb: TracebackType | None = ..., ) -> None: ... diff --git a/stdlib/shelve.pyi b/stdlib/shelve.pyi index 90b2aafa4..10f82b6a2 100644 --- a/stdlib/shelve.pyi +++ b/stdlib/shelve.pyi @@ -1,7 +1,7 @@ from _typeshed import Self from collections.abc import Iterator, MutableMapping from types import TracebackType -from typing import Type, TypeVar, overload +from typing import TypeVar, overload _T = TypeVar("_T") _VT = TypeVar("_VT") @@ -21,7 +21,7 @@ class Shelf(MutableMapping[str, _VT]): def __delitem__(self, key: str) -> None: ... def __enter__(self: Self) -> Self: ... 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 close(self) -> None: ... def sync(self) -> None: ... diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index e5401552c..8a532058a 100644 --- a/stdlib/smtpd.pyi +++ b/stdlib/smtpd.pyi @@ -2,7 +2,7 @@ import asynchat import asyncore import socket from collections import defaultdict -from typing import Any, Type +from typing import Any _Address = tuple[str, int] # (host, port) @@ -56,7 +56,7 @@ class SMTPChannel(asynchat.async_chat): def smtp_EXPN(self, arg: str) -> None: ... class SMTPServer(asyncore.dispatcher): - channel_class: Type[SMTPChannel] + channel_class: type[SMTPChannel] data_size_limit: int enable_SMTPUTF8: bool diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 0a57f1f5d..4e4fb1648 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -4,7 +4,7 @@ from email.message import Message as _Message from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Pattern, Protocol, Sequence, Type, Union, overload +from typing import Any, Pattern, Protocol, Sequence, Union, overload _Reply = tuple[int, bytes] _SendErrs = dict[str, _Reply] @@ -79,7 +79,7 @@ class SMTP: ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None ) -> None: ... def set_debuglevel(self, debuglevel: int) -> None: ... def connect(self, host: str = ..., port: int = ..., source_address: _SourceAddress | None = ...) -> _Reply: ... diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index cbbb1d1f5..b50d816f3 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -2,7 +2,7 @@ import sys import types from _typeshed import Self from socket import socket as _socket -from typing import Any, BinaryIO, Callable, ClassVar, Type, Union +from typing import Any, BinaryIO, Callable, ClassVar, Union _RequestType = Union[_socket, tuple[bytes, _socket]] _AddressType = Union[tuple[str, int], str] @@ -32,7 +32,7 @@ class BaseServer: def verify_request(self, request: _RequestType, client_address: _AddressType) -> bool: ... def __enter__(self: Self) -> Self: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... def service_actions(self) -> None: ... def shutdown_request(self, request: _RequestType) -> None: ... # undocumented diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index ea9098940..32b4a2e95 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from datetime import date, datetime, time -from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, Type, TypeVar +from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, TypeVar _T = TypeVar("_T") @@ -94,7 +94,7 @@ if sys.version_info >= (3, 7): detect_types: int = ..., isolation_level: str | None = ..., check_same_thread: bool = ..., - factory: Type[Connection] | None = ..., + factory: type[Connection] | None = ..., cached_statements: int = ..., uri: bool = ..., ) -> Connection: ... @@ -106,14 +106,14 @@ else: detect_types: int = ..., isolation_level: str | None = ..., check_same_thread: bool = ..., - factory: Type[Connection] | None = ..., + factory: type[Connection] | None = ..., cached_statements: int = ..., uri: bool = ..., ) -> Connection: ... def enable_callback_tracebacks(__enable: bool) -> None: ... def enable_shared_cache(enable: int) -> None: ... -def register_adapter(__type: Type[_T], __caster: Callable[[_T], int | float | str | bytes]) -> None: ... +def register_adapter(__type: type[_T], __caster: Callable[[_T], int | float | str | bytes]) -> None: ... def register_converter(__name: str, __converter: Callable[[bytes], Any]) -> None: ... if sys.version_info < (3, 8): diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index cdb727285..8851c94ef 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -2,7 +2,7 @@ import enum import socket import sys from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer -from typing import Any, Callable, ClassVar, Iterable, NamedTuple, Optional, Type, Union, overload +from typing import Any, Callable, ClassVar, Iterable, NamedTuple, Optional, Union, overload from typing_extensions import Literal, TypedDict _PCTRTT = tuple[tuple[str, str], ...] @@ -294,9 +294,9 @@ class _ASN1Object(NamedTuple): longname: str oid: str @classmethod - def fromnid(cls: Type[Self], nid: int) -> Self: ... + def fromnid(cls: type[Self], nid: int) -> Self: ... @classmethod - def fromname(cls: Type[Self], name: str) -> Self: ... + def fromname(cls: type[Self], name: str) -> Self: ... class Purpose(_ASN1Object, enum.Enum): SERVER_AUTH: _ASN1Object @@ -391,8 +391,8 @@ class SSLContext: maximum_version: TLSVersion minimum_version: TLSVersion sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None - sslobject_class: ClassVar[Type[SSLObject]] - sslsocket_class: ClassVar[Type[SSLSocket]] + sslobject_class: ClassVar[type[SSLObject]] + sslsocket_class: ClassVar[type[SSLSocket]] if sys.version_info >= (3, 8): keylog_filename: str post_handshake_auth: bool diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 908d6adaf..b92a05466 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import SupportsRichComparisonT from decimal import Decimal from fractions import Fraction -from typing import Any, Hashable, Iterable, NamedTuple, Sequence, SupportsFloat, Type, TypeVar, Union +from typing import Any, Hashable, Iterable, NamedTuple, Sequence, SupportsFloat, TypeVar, Union _T = TypeVar("_T") # Most functions in this module accept homogeneous collections of one of these types @@ -58,7 +58,7 @@ if sys.version_info >= (3, 8): @property def variance(self) -> float: ... @classmethod - def from_samples(cls: Type[_T], data: Iterable[SupportsFloat]) -> _T: ... + def from_samples(cls: type[_T], data: Iterable[SupportsFloat]) -> _T: ... def samples(self, n: int, *, seed: Any | None = ...) -> list[float]: ... def pdf(self, x: float) -> float: ... def cdf(self, x: float) -> float: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index fce517745..b0987f399 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self, StrOrBytesPath from types import TracebackType -from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, Type, TypeVar, Union, overload +from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -1008,7 +1008,7 @@ class Popen(Generic[AnyStr]): def kill(self) -> None: ... def __enter__(self: Self) -> Self: ... 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: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index 93c9a27dd..d42e1e0f9 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -5,13 +5,13 @@ from importlib.abc import PathEntryFinder from importlib.machinery import ModuleSpec from io import TextIOWrapper from types import FrameType, ModuleType, TracebackType -from typing import Any, AsyncGenerator, Callable, NoReturn, Optional, Protocol, Sequence, TextIO, Type, TypeVar, Union, overload +from typing import Any, AsyncGenerator, Callable, NoReturn, Optional, Protocol, Sequence, TextIO, TypeVar, Union, overload from typing_extensions import Literal, final _T = TypeVar("_T") # The following type alias are stub-only and do not exist during runtime -_ExcInfo = tuple[Type[BaseException], BaseException, TracebackType] +_ExcInfo = tuple[type[BaseException], BaseException, TracebackType] _OptExcInfo = Union[_ExcInfo, tuple[None, None, None]] # Intentionally omits one deprecated and one optional method of `importlib.abc.MetaPathFinder` @@ -31,12 +31,12 @@ if sys.platform == "win32": dllhandle: int dont_write_bytecode: bool displayhook: Callable[[object], Any] -excepthook: Callable[[Type[BaseException], BaseException, TracebackType | None], Any] +excepthook: Callable[[type[BaseException], BaseException, TracebackType | None], Any] exec_prefix: str executable: str float_repr_style: Literal["short", "legacy"] hexversion: int -last_type: Type[BaseException] | None +last_type: type[BaseException] | None last_value: BaseException | None last_traceback: TracebackType | None maxsize: int @@ -216,7 +216,7 @@ def _current_frames() -> dict[int, FrameType]: ... def _getframe(__depth: int = ...) -> FrameType: ... def _debugmallocstats() -> None: ... def __displayhook__(value: object) -> None: ... -def __excepthook__(type_: Type[BaseException], value: BaseException, traceback: TracebackType | None) -> None: ... +def __excepthook__(type_: type[BaseException], value: BaseException, traceback: TracebackType | None) -> None: ... def exc_info() -> _OptExcInfo: ... # sys.exit() accepts an optional argument of anything printable @@ -294,7 +294,7 @@ if sys.version_info < (3, 9): if sys.version_info >= (3, 8): # Doesn't exist at runtime, but exported in the stubs so pytest etc. can annotate their code more easily. class UnraisableHookArgs: - exc_type: Type[BaseException] + exc_type: type[BaseException] exc_value: BaseException | None exc_traceback: TracebackType | None err_msg: str | None diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 4931a6f0e..73b50c298 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -5,7 +5,7 @@ from _typeshed import Self, StrOrBytesPath, StrPath from collections.abc import Callable, Iterable, Iterator, Mapping from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj from types import TracebackType -from typing import IO, Protocol, Type, TypeVar, overload +from typing import IO, Protocol, TypeVar, overload from typing_extensions import Literal _TF = TypeVar("_TF", bound=TarFile) @@ -78,7 +78,7 @@ def open( bufsize: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -100,12 +100,12 @@ class TarFile: mode: Literal["r", "a", "w", "x"] fileobj: _Fileobj | None format: int | None - tarinfo: Type[TarInfo] + tarinfo: type[TarInfo] dereference: bool | None ignore_zeros: bool | None encoding: str | None errors: str - fileobject: Type[ExFileObject] + fileobject: type[ExFileObject] pax_headers: Mapping[str, str] | None debug: int | None errorlevel: int | None @@ -116,7 +116,7 @@ class TarFile: mode: Literal["r", "a", "w", "x"] = ..., fileobj: _Fileobj | None = ..., format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -128,19 +128,19 @@ class TarFile: ) -> 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 __iter__(self) -> Iterator[TarInfo]: ... @classmethod def open( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None = ..., mode: str = ..., fileobj: IO[bytes] | None = ..., # depends on mode bufsize: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -151,14 +151,14 @@ class TarFile: ) -> _TF: ... @classmethod def taropen( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["r", "a", "w", "x"] = ..., fileobj: _Fileobj | None = ..., *, compresslevel: int = ..., format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -169,14 +169,14 @@ class TarFile: @overload @classmethod def gzopen( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["r"] = ..., fileobj: _GzipReadableFileobj | None = ..., compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -187,14 +187,14 @@ class TarFile: @overload @classmethod def gzopen( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["w", "x"], fileobj: _GzipWritableFileobj | None = ..., compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -205,14 +205,14 @@ class TarFile: @overload @classmethod def bz2open( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["w", "x"], fileobj: _Bz2WritableFileobj | None = ..., compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -223,14 +223,14 @@ class TarFile: @overload @classmethod def bz2open( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["r"] = ..., fileobj: _Bz2ReadableFileobj | None = ..., compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., @@ -240,14 +240,14 @@ class TarFile: ) -> _TF: ... @classmethod def xzopen( - cls: Type[_TF], + cls: type[_TF], name: StrOrBytesPath | None, mode: Literal["r", "w", "x"] = ..., fileobj: IO[bytes] | None = ..., preset: int | None = ..., *, format: int | None = ..., - tarinfo: Type[TarInfo] | None = ..., + tarinfo: type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 4aec26175..9b5e2bb82 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -2,7 +2,7 @@ import os import sys from _typeshed import Self from types import TracebackType -from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, Type, Union, overload +from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -169,7 +169,7 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): delete: bool def __init__(self, file: IO[AnyStr], name: str, delete: bool = ...) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, exc: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> bool | None: ... + def __exit__(self, exc: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> bool | None: ... def __getattr__(self, name: str) -> Any: ... def close(self) -> None: ... # These methods don't exist directly on this object, but @@ -293,7 +293,7 @@ class SpooledTemporaryFile(IO[AnyStr]): def rollover(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 ) -> bool | None: ... # These methods are copied from the abstract methods of IO, because # SpooledTemporaryFile implements IO. @@ -346,7 +346,7 @@ class TemporaryDirectory(Generic[AnyStr]): def cleanup(self) -> None: ... def __enter__(self) -> AnyStr: ... 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: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index 3e91221ba..10853ff87 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -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]]] @@ -75,7 +75,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: ... @@ -87,7 +87,7 @@ class _RLock: def release(self) -> None: ... __enter__ = acquire 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: ... RLock = _RLock @@ -96,7 +96,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: ... @@ -109,7 +109,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: ... diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 50de97f48..9d04c74ba 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -5,7 +5,7 @@ from enum import Enum from tkinter.constants import * from tkinter.font import _FontDescription from types import TracebackType -from typing import Any, Callable, Generic, Mapping, Optional, Protocol, Sequence, Type, TypeVar, Union, overload +from typing import Any, Callable, Generic, Mapping, Optional, Protocol, Sequence, TypeVar, Union, overload from typing_extensions import Literal, TypedDict # Using anything from tkinter.font in this file means that 'import tkinter' @@ -571,7 +571,7 @@ class Wm: withdraw = wm_withdraw class _ExceptionReportingCallback(Protocol): - def __call__(self, __exc: Type[BaseException], __val: BaseException, __tb: TracebackType | None) -> Any: ... + def __call__(self, __exc: type[BaseException], __val: BaseException, __tb: TracebackType | None) -> Any: ... class Tk(Misc, Wm): master: None diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index 4e36490c2..09d817cf2 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import SupportsWrite from types import FrameType, TracebackType -from typing import IO, Any, Generator, Iterable, Iterator, Mapping, Optional, Type, overload +from typing import IO, Any, Generator, Iterable, Iterator, Mapping, Optional, overload _PT = tuple[str, int, str, Optional[str]] @@ -10,7 +10,7 @@ def print_tb(tb: TracebackType | None, limit: int | None = ..., file: IO[str] | if sys.version_info >= (3, 10): @overload def print_exception( - __exc: Type[BaseException] | None, + __exc: type[BaseException] | None, value: BaseException | None = ..., tb: TracebackType | None = ..., limit: int | None = ..., @@ -23,7 +23,7 @@ if sys.version_info >= (3, 10): ) -> None: ... @overload def format_exception( - __exc: Type[BaseException] | None, + __exc: type[BaseException] | None, value: BaseException | None = ..., tb: TracebackType | None = ..., limit: int | None = ..., @@ -34,7 +34,7 @@ if sys.version_info >= (3, 10): else: def print_exception( - etype: Type[BaseException] | None, + etype: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, limit: int | None = ..., @@ -42,7 +42,7 @@ else: chain: bool = ..., ) -> None: ... def format_exception( - etype: Type[BaseException] | None, + etype: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, limit: int | None = ..., @@ -60,10 +60,10 @@ def format_list(extracted_list: list[FrameSummary]) -> list[str]: ... def print_list(extracted_list: list[FrameSummary], file: SupportsWrite[str] | None = ...) -> None: ... if sys.version_info >= (3, 10): - def format_exception_only(__exc: Type[BaseException] | None, value: BaseException | None = ...) -> list[str]: ... + def format_exception_only(__exc: type[BaseException] | None, value: BaseException | None = ...) -> list[str]: ... else: - def format_exception_only(etype: Type[BaseException] | None, value: BaseException | None) -> list[str]: ... + def format_exception_only(etype: type[BaseException] | None, value: BaseException | None) -> list[str]: ... def format_exc(limit: int | None = ..., chain: bool = ...) -> str: ... def format_tb(tb: TracebackType | None, limit: int | None = ...) -> list[str]: ... @@ -77,7 +77,7 @@ class TracebackException: __context__: TracebackException __suppress_context__: bool stack: StackSummary - exc_type: Type[BaseException] + exc_type: type[BaseException] filename: str lineno: int text: str @@ -86,7 +86,7 @@ class TracebackException: if sys.version_info >= (3, 10): def __init__( self, - exc_type: Type[BaseException], + exc_type: type[BaseException], exc_value: BaseException, exc_traceback: TracebackType | None, *, @@ -109,7 +109,7 @@ class TracebackException: else: def __init__( self, - exc_type: Type[BaseException], + exc_type: type[BaseException], exc_value: BaseException, exc_traceback: TracebackType | None, *, diff --git a/stdlib/types.pyi b/stdlib/types.pyi index f290f626b..5cad8badf 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -16,7 +16,6 @@ from typing import ( KeysView, Mapping, MutableSequence, - Type, TypeVar, ValuesView, overload, @@ -220,7 +219,7 @@ class GeneratorType(Generator[_T_co, _T_contra, _V_co]): def send(self, __arg: _T_contra) -> _T_co: ... @overload def throw( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... + self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... ) -> _T_co: ... @overload def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... @@ -236,7 +235,7 @@ class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]): def asend(self, __val: _T_contra) -> Awaitable[_T_co]: ... @overload def athrow( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... + self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... ) -> Awaitable[_T_co]: ... @overload def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Awaitable[_T_co]: ... @@ -257,7 +256,7 @@ class CoroutineType(Coroutine[_T_co, _T_contra, _V_co]): def send(self, __arg: _T_contra) -> _T_co: ... @overload def throw( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... + self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... ) -> _T_co: ... @overload def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index e7f288377..2fc3d2474 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -31,7 +31,7 @@ from typing import ( _T = TypeVar("_T") _F = TypeVar("_F", bound=Callable[..., Any]) -_TC = TypeVar("_TC", bound=Type[object]) +_TC = TypeVar("_TC", bound=type[object]) class _SpecialForm: def __getitem__(self, typeargs: Any) -> Any: ... @@ -109,11 +109,11 @@ else: def __init__(self, origin: ParamSpec) -> None: ... class ParamSpec: __name__: str - __bound__: Type[Any] | None + __bound__: type[Any] | None __covariant__: bool __contravariant__: bool def __init__( - self, name: str, *, bound: None | Type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ... + self, name: str, *, bound: None | type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ... ) -> None: ... @property def args(self) -> ParamSpecArgs: ... diff --git a/stdlib/unittest/_log.pyi b/stdlib/unittest/_log.pyi index f9e406199..947a2158d 100644 --- a/stdlib/unittest/_log.pyi +++ b/stdlib/unittest/_log.pyi @@ -1,7 +1,7 @@ import logging import sys from types import TracebackType -from typing import ClassVar, Generic, NamedTuple, Type, TypeVar +from typing import ClassVar, Generic, NamedTuple, TypeVar from unittest.case import TestCase _L = TypeVar("_L", None, _LoggingWatcher) @@ -23,5 +23,5 @@ class _AssertLogsContext(Generic[_L]): def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ... def __enter__(self) -> _L: ... 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: ... diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 858bf38e7..2ff01a32b 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -19,7 +19,6 @@ from typing import ( NoReturn, Pattern, Sequence, - Type, TypeVar, overload, ) @@ -55,7 +54,7 @@ else: def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ... def __enter__(self) -> _LoggingWatcher: ... 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: ... if sys.version_info >= (3, 8): @@ -71,7 +70,7 @@ class SkipTest(Exception): def __init__(self, reason: str) -> None: ... class TestCase: - failureException: Type[BaseException] + failureException: type[BaseException] longMessage: bool maxDiff: int | None # undocumented @@ -110,17 +109,17 @@ class TestCase: @overload def assertRaises( # type: ignore[misc] self, - expected_exception: Type[BaseException] | tuple[Type[BaseException], ...], + expected_exception: type[BaseException] | tuple[type[BaseException], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any, ) -> None: ... @overload - def assertRaises(self, expected_exception: Type[_E] | tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... + def assertRaises(self, expected_exception: type[_E] | tuple[type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... @overload def assertRaisesRegex( # type: ignore[misc] self, - expected_exception: Type[BaseException] | tuple[Type[BaseException], ...], + expected_exception: type[BaseException] | tuple[type[BaseException], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, @@ -129,20 +128,20 @@ class TestCase: @overload def assertRaisesRegex( self, - expected_exception: Type[_E] | tuple[Type[_E], ...], + expected_exception: type[_E] | tuple[type[_E], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertRaisesContext[_E]: ... @overload def assertWarns( # type: ignore[misc] - self, expected_warning: Type[Warning] | tuple[Type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any + self, expected_warning: type[Warning] | tuple[type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any ) -> None: ... @overload - def assertWarns(self, expected_warning: Type[Warning] | tuple[Type[Warning], ...], msg: Any = ...) -> _AssertWarnsContext: ... + def assertWarns(self, expected_warning: type[Warning] | tuple[type[Warning], ...], msg: Any = ...) -> _AssertWarnsContext: ... @overload def assertWarnsRegex( # type: ignore[misc] self, - expected_warning: Type[Warning] | tuple[Type[Warning], ...], + expected_warning: type[Warning] | tuple[type[Warning], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, @@ -151,7 +150,7 @@ class TestCase: @overload def assertWarnsRegex( self, - expected_warning: Type[Warning] | tuple[Type[Warning], ...], + expected_warning: type[Warning] | tuple[type[Warning], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertWarnsContext: ... @@ -193,10 +192,10 @@ class TestCase: def assertRegex(self, text: AnyStr, expected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ... def assertNotRegex(self, text: AnyStr, unexpected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ... def assertCountEqual(self, first: Iterable[Any], second: Iterable[Any], msg: Any = ...) -> None: ... - def addTypeEqualityFunc(self, typeobj: Type[Any], function: Callable[..., None]) -> None: ... + def addTypeEqualityFunc(self, typeobj: type[Any], function: Callable[..., None]) -> None: ... def assertMultiLineEqual(self, first: str, second: str, msg: Any = ...) -> None: ... def assertSequenceEqual( - self, seq1: Sequence[Any], seq2: Sequence[Any], msg: Any = ..., seq_type: Type[Sequence[Any]] | None = ... + self, seq1: Sequence[Any], seq2: Sequence[Any], msg: Any = ..., seq_type: type[Sequence[Any]] | None = ... ) -> None: ... def assertListEqual(self, list1: list[Any], list2: list[Any], msg: Any = ...) -> None: ... def assertTupleEqual(self, tuple1: tuple[Any, ...], tuple2: tuple[Any, ...], msg: Any = ...) -> None: ... @@ -230,13 +229,13 @@ class TestCase: @overload def failUnlessRaises( # type: ignore[misc] self, - exception: Type[BaseException] | tuple[Type[BaseException], ...], + exception: type[BaseException] | tuple[type[BaseException], ...], callable: Callable[..., Any] = ..., *args: Any, **kwargs: Any, ) -> None: ... @overload - def failUnlessRaises(self, exception: Type[_E] | tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... + def failUnlessRaises(self, exception: type[_E] | tuple[type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ... def failUnlessAlmostEqual(self, first: float, second: float, places: int = ..., msg: Any = ...) -> None: ... def assertAlmostEquals( self, first: float, second: float, places: int = ..., msg: Any = ..., delta: float = ... @@ -250,7 +249,7 @@ class TestCase: @overload def assertRaisesRegexp( # type: ignore[misc] self, - exception: Type[BaseException] | tuple[Type[BaseException], ...], + exception: type[BaseException] | tuple[type[BaseException], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], callable: Callable[..., Any], *args: Any, @@ -259,7 +258,7 @@ class TestCase: @overload def assertRaisesRegexp( self, - exception: Type[_E] | tuple[Type[_E], ...], + exception: type[_E] | tuple[type[_E], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], msg: Any = ..., ) -> _AssertRaisesContext[_E]: ... @@ -281,7 +280,7 @@ class _AssertRaisesContext(Generic[_E]): exception: _E 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 ) -> bool: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -293,5 +292,5 @@ class _AssertWarnsContext: warnings: list[WarningMessage] 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: ... diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index aca7e4f95..8b3c82233 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -3,7 +3,7 @@ import unittest.case import unittest.result import unittest.suite from types import ModuleType -from typing import Any, Callable, Pattern, Sequence, Type +from typing import Any, Callable, Pattern, Sequence _SortComparisonMethod = Callable[[str, str], int] _SuiteClass = Callable[[list[unittest.case.TestCase]], unittest.suite.TestSuite] @@ -11,7 +11,7 @@ _SuiteClass = Callable[[list[unittest.case.TestCase]], unittest.suite.TestSuite] VALID_MODULE_NAME: Pattern[str] class TestLoader: - errors: list[Type[BaseException]] + errors: list[type[BaseException]] testMethodPrefix: str sortTestMethodsUsing: _SortComparisonMethod @@ -19,18 +19,18 @@ class TestLoader: testNamePatterns: list[str] | None suiteClass: _SuiteClass - def loadTestsFromTestCase(self, testCaseClass: Type[unittest.case.TestCase]) -> unittest.suite.TestSuite: ... + def loadTestsFromTestCase(self, testCaseClass: type[unittest.case.TestCase]) -> unittest.suite.TestSuite: ... def loadTestsFromModule(self, module: ModuleType, *args: Any, pattern: Any = ...) -> unittest.suite.TestSuite: ... def loadTestsFromName(self, name: str, module: ModuleType | None = ...) -> unittest.suite.TestSuite: ... def loadTestsFromNames(self, names: Sequence[str], module: ModuleType | None = ...) -> unittest.suite.TestSuite: ... - def getTestCaseNames(self, testCaseClass: Type[unittest.case.TestCase]) -> Sequence[str]: ... + def getTestCaseNames(self, testCaseClass: type[unittest.case.TestCase]) -> Sequence[str]: ... def discover(self, start_dir: str, pattern: str = ..., top_level_dir: str | None = ...) -> unittest.suite.TestSuite: ... defaultTestLoader: TestLoader if sys.version_info >= (3, 7): def getTestCaseNames( - testCaseClass: Type[unittest.case.TestCase], + testCaseClass: type[unittest.case.TestCase], prefix: str, sortUsing: _SortComparisonMethod = ..., testNamePatterns: list[str] | None = ..., @@ -38,11 +38,11 @@ if sys.version_info >= (3, 7): else: def getTestCaseNames( - testCaseClass: Type[unittest.case.TestCase], prefix: str, sortUsing: _SortComparisonMethod = ... + testCaseClass: type[unittest.case.TestCase], prefix: str, sortUsing: _SortComparisonMethod = ... ) -> Sequence[str]: ... def makeSuite( - testCaseClass: Type[unittest.case.TestCase], + testCaseClass: type[unittest.case.TestCase], prefix: str = ..., sortUsing: _SortComparisonMethod = ..., suiteClass: _SuiteClass = ..., diff --git a/stdlib/unittest/main.pyi b/stdlib/unittest/main.pyi index 6d1117eca..16c48ebdd 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -4,7 +4,7 @@ import unittest.loader import unittest.result import unittest.suite from types import ModuleType -from typing import Any, Iterable, Protocol, Type +from typing import Any, Iterable, Protocol MAIN_EXAMPLES: str MODULE_EXAMPLES: str @@ -30,7 +30,7 @@ class TestProgram: module: None | str | ModuleType = ..., defaultTest: str | Iterable[str] | None = ..., argv: list[str] | None = ..., - testRunner: Type[_TestRunner] | _TestRunner | None = ..., + testRunner: type[_TestRunner] | _TestRunner | None = ..., testLoader: unittest.loader.TestLoader = ..., exit: bool = ..., verbosity: int = ..., diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index fc0ceb014..eb6942d5d 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -1,8 +1,8 @@ import sys -from typing import Any, Awaitable, Callable, Generic, Iterable, Mapping, Sequence, Type, TypeVar, overload +from typing import Any, Awaitable, Callable, Generic, Iterable, Mapping, Sequence, TypeVar, overload _T = TypeVar("_T") -_TT = TypeVar("_TT", bound=Type[Any]) +_TT = TypeVar("_TT", bound=type[Any]) _R = TypeVar("_R") if sys.version_info >= (3, 8): @@ -106,10 +106,10 @@ class NonCallableMock(Base, Any): def __new__(__cls, *args: Any, **kw: Any) -> NonCallableMock: ... def __init__( self, - spec: list[str] | object | Type[object] | None = ..., + spec: list[str] | object | type[object] | None = ..., wraps: Any | None = ..., name: str | None = ..., - spec_set: list[str] | object | Type[object] | None = ..., + spec_set: list[str] | object | type[object] | None = ..., parent: NonCallableMock | None = ..., _spec_state: Any | None = ..., _new_name: str = ..., @@ -258,7 +258,7 @@ class _patch_dict: class _patcher: TEST_PREFIX: str - dict: Type[_patch_dict] + dict: type[_patch_dict] if sys.version_info >= (3, 8): # This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any]. # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock], diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index 9a19aef77..1c79f8ab6 100644 --- a/stdlib/unittest/result.pyi +++ b/stdlib/unittest/result.pyi @@ -1,8 +1,8 @@ import unittest.case from types import TracebackType -from typing import Any, Callable, TextIO, Type, TypeVar, Union +from typing import Any, Callable, TextIO, TypeVar, Union -_SysExcInfoType = Union[tuple[Type[BaseException], BaseException, TracebackType], tuple[None, None, None]] +_SysExcInfoType = Union[tuple[type[BaseException], BaseException, TracebackType], tuple[None, None, None]] _F = TypeVar("_F", bound=Callable[..., Any]) diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index 85481880a..eb6383074 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -1,7 +1,7 @@ import unittest.case import unittest.result import unittest.suite -from typing import Callable, TextIO, Type +from typing import Callable, TextIO _ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult] @@ -27,7 +27,7 @@ class TextTestRunner: failfast: bool = ..., buffer: bool = ..., resultclass: _ResultClassType | None = ..., - warnings: Type[Warning] | None = ..., + warnings: type[Warning] | None = ..., *, tb_locals: bool = ..., ) -> None: ... diff --git a/stdlib/urllib/response.pyi b/stdlib/urllib/response.pyi index 18b498b40..c52b96e07 100644 --- a/stdlib/urllib/response.pyi +++ b/stdlib/urllib/response.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import Self from email.message import Message from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, Type, TypeVar +from typing import IO, Any, BinaryIO, Callable, Iterable, TypeVar _AIUT = TypeVar("_AIUT", bound=addbase) @@ -11,7 +11,7 @@ class addbase(BinaryIO): def __init__(self, fp: IO[bytes]) -> None: ... def __enter__(self: Self) -> Self: ... 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 __iter__(self: _AIUT) -> _AIUT: ... def __next__(self) -> bytes: ... diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index b1c9f4dda..714356162 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,32 +1,32 @@ from _warnings import warn as warn, warn_explicit as warn_explicit from types import ModuleType, TracebackType -from typing import Any, Sequence, TextIO, Type, overload +from typing import Any, Sequence, TextIO, overload from typing_extensions import Literal _ActionKind = Literal["default", "error", "ignore", "always", "module", "once"] -filters: Sequence[tuple[str, str | None, Type[Warning], str | None, int]] # undocumented, do not mutate +filters: Sequence[tuple[str, str | None, type[Warning], str | None, int]] # undocumented, do not mutate def showwarning( - message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ... + message: Warning | str, category: type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ... ) -> None: ... -def formatwarning(message: Warning | str, category: Type[Warning], filename: str, lineno: int, line: str | None = ...) -> str: ... +def formatwarning(message: Warning | str, category: type[Warning], filename: str, lineno: int, line: str | None = ...) -> str: ... def filterwarnings( action: _ActionKind, message: str = ..., - category: Type[Warning] = ..., + category: type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ..., ) -> None: ... -def simplefilter(action: _ActionKind, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ... +def simplefilter(action: _ActionKind, category: type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ... def resetwarnings() -> None: ... class _OptionError(Exception): ... class WarningMessage: message: Warning | str - category: Type[Warning] + category: type[Warning] filename: str lineno: int file: TextIO | None @@ -35,7 +35,7 @@ class WarningMessage: def __init__( self, message: Warning | str, - category: Type[Warning], + category: type[Warning], filename: str, lineno: int, file: TextIO | None = ..., @@ -52,7 +52,7 @@ class catch_warnings: def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ... def __enter__(self) -> list[WarningMessage] | 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 ) -> None: ... class _catch_warnings_without_records(catch_warnings): diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index f60927595..363f939a6 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -1,5 +1,5 @@ from _weakrefset import WeakSet as WeakSet -from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, MutableMapping, Type, TypeVar, overload +from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, MutableMapping, TypeVar, overload from _weakref import ( CallableProxyType as CallableProxyType, @@ -16,7 +16,7 @@ _KT = TypeVar("_KT") _VT = TypeVar("_VT") _CallableT = TypeVar("_CallableT", bound=Callable[..., Any]) -ProxyTypes: tuple[Type[Any], ...] +ProxyTypes: tuple[type[Any], ...] class WeakMethod(ref[_CallableT], Generic[_CallableT]): def __new__(cls, meth: _CallableT, callback: Callable[[_CallableT], object] | None = ...) -> WeakMethod[_CallableT]: ... diff --git a/stdlib/winreg.pyi b/stdlib/winreg.pyi index 57f0c4b3d..1730c651c 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import Self from types import TracebackType -from typing import Any, Type, Union +from typing import Any, Union from typing_extensions import Literal, final if sys.platform == "win32": @@ -95,7 +95,7 @@ if sys.platform == "win32": def __int__(self) -> int: ... 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 ) -> bool | None: ... def Close(self) -> None: ... def Detach(self) -> int: ... diff --git a/stdlib/wsgiref/handlers.pyi b/stdlib/wsgiref/handlers.pyi index eccc0d164..11f474660 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -1,12 +1,12 @@ from abc import abstractmethod from types import TracebackType -from typing import IO, Callable, MutableMapping, Optional, Type +from typing import IO, Callable, MutableMapping, Optional from .headers import Headers from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment from .util import FileWrapper -_exc_info = tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_exc_info = tuple[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]] def format_date_time(timestamp: float | None) -> str: ... # undocumented def read_environ() -> dict[str, str]: ... @@ -23,8 +23,8 @@ class BaseHandler: os_environ: MutableMapping[str, str] - wsgi_file_wrapper: Type[FileWrapper] | None - headers_class: Type[Headers] # undocumented + wsgi_file_wrapper: type[FileWrapper] | None + headers_class: type[Headers] # undocumented traceback_limit: int | None error_status: str diff --git a/stdlib/wsgiref/simple_server.pyi b/stdlib/wsgiref/simple_server.pyi index 76d0b2697..7e746451d 100644 --- a/stdlib/wsgiref/simple_server.pyi +++ b/stdlib/wsgiref/simple_server.pyi @@ -1,5 +1,5 @@ from http.server import BaseHTTPRequestHandler, HTTPServer -from typing import Type, TypeVar, overload +from typing import TypeVar, overload from .handlers import SimpleHandler from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment @@ -30,8 +30,8 @@ def demo_app(environ: WSGIEnvironment, start_response: StartResponse) -> list[by _S = TypeVar("_S", bound=WSGIServer) @overload -def make_server(host: str, port: int, app: WSGIApplication, *, handler_class: Type[WSGIRequestHandler] = ...) -> WSGIServer: ... +def make_server(host: str, port: int, app: WSGIApplication, *, handler_class: type[WSGIRequestHandler] = ...) -> WSGIServer: ... @overload def make_server( - host: str, port: int, app: WSGIApplication, server_class: Type[_S], handler_class: Type[WSGIRequestHandler] = ... + host: str, port: int, app: WSGIApplication, server_class: type[_S], handler_class: type[WSGIRequestHandler] = ... ) -> _S: ... diff --git a/stdlib/xml/dom/minicompat.pyi b/stdlib/xml/dom/minicompat.pyi index 38e6d05e4..e37b7cd89 100644 --- a/stdlib/xml/dom/minicompat.pyi +++ b/stdlib/xml/dom/minicompat.pyi @@ -1,8 +1,8 @@ -from typing import Any, Iterable, Type, TypeVar +from typing import Any, Iterable, TypeVar _T = TypeVar("_T") -StringTypes: tuple[Type[str]] +StringTypes: tuple[type[str]] class NodeList(list[_T]): length: int @@ -14,4 +14,4 @@ class EmptyNodeList(tuple[Any, ...]): def __add__(self, other: Iterable[_T]) -> NodeList[_T]: ... # type: ignore[override] def __radd__(self, other: Iterable[_T]) -> NodeList[_T]: ... -def defproperty(klass: Type[Any], name: str, doc: str) -> None: ... +def defproperty(klass: type[Any], name: str, doc: str) -> None: ... diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index e9f9e03ae..03a6ac69f 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -6,7 +6,7 @@ from _typeshed import Self, SupportsRead, SupportsWrite from datetime import datetime from io import BytesIO from types import TracebackType -from typing import Any, Callable, Iterable, Mapping, Protocol, Type, Union, overload +from typing import Any, Callable, Iterable, Mapping, Protocol, Union, overload from typing_extensions import Literal class _SupportsTimeTuple(Protocol): @@ -86,7 +86,7 @@ class Binary: def _binary(data: bytes) -> Binary: ... # undocumented -WRAPPERS: tuple[Type[DateTime], Type[Binary]] # undocumented +WRAPPERS: tuple[type[DateTime], type[Binary]] # undocumented class ExpatParser: # undocumented def __init__(self, target: Unmarshaller) -> None: ... @@ -96,7 +96,7 @@ class ExpatParser: # undocumented class Marshaller: dispatch: dict[ - Type[Any], Callable[[Marshaller, Any, Callable[[str], Any]], None] + type[Any], Callable[[Marshaller, Any, Callable[[str], Any]], None] ] # TODO: Replace 'Any' with some kind of binding memo: dict[Any, None] @@ -301,7 +301,7 @@ class ServerProxy: def __call__(self, attr: str) -> Callable[[], None] | Transport: ... 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 __close(self) -> None: ... # undocumented def __request(self, methodname: str, params: tuple[_Marshallable, ...]) -> tuple[_Marshallable, ...]: ... # undocumented diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index 48105d146..650a65945 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -3,7 +3,7 @@ import pydoc import socketserver import sys from datetime import datetime -from typing import Any, Callable, Iterable, Mapping, Pattern, Protocol, Type, Union +from typing import Any, Callable, Iterable, Mapping, Pattern, Protocol, Union from xmlrpc.client import Fault # TODO: Recursive type on tuple, list, dict @@ -81,7 +81,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer, SimpleXMLRPCDispatcher): def __init__( self, addr: tuple[str, int], - requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., + requestHandler: type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: str | None = ..., @@ -97,7 +97,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented def __init__( self, addr: tuple[str, int], - requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., + requestHandler: type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: str | None = ..., @@ -150,7 +150,7 @@ class DocXMLRPCServer(SimpleXMLRPCServer, XMLRPCDocGenerator): def __init__( self, addr: tuple[str, int], - requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., + requestHandler: type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: str | None = ..., diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index c64690ba8..4244229a1 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -3,7 +3,7 @@ import sys from _typeshed import Self, StrPath from os import PathLike from types import TracebackType -from typing import IO, Any, Callable, Iterable, Iterator, Protocol, Sequence, Type, overload +from typing import IO, Any, Callable, Iterable, Iterator, Protocol, Sequence, overload from typing_extensions import Literal _DateTuple = tuple[int, int, int, int, int, int] @@ -145,7 +145,7 @@ class ZipFile: ) -> 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 close(self) -> None: ... def getinfo(self, name: str) -> ZipInfo: ... diff --git a/stdlib/zoneinfo/__init__.pyi b/stdlib/zoneinfo/__init__.pyi index 4f924e0cc..1170b3548 100644 --- a/stdlib/zoneinfo/__init__.pyi +++ b/stdlib/zoneinfo/__init__.pyi @@ -1,7 +1,7 @@ import typing from _typeshed import StrPath from datetime import tzinfo -from typing import Any, Iterable, Protocol, Sequence, Type +from typing import Any, Iterable, Protocol, Sequence _T = typing.TypeVar("_T", bound="ZoneInfo") @@ -14,9 +14,9 @@ class ZoneInfo(tzinfo): def key(self) -> str: ... def __init__(self, key: str) -> None: ... @classmethod - def no_cache(cls: Type[_T], key: str) -> _T: ... + def no_cache(cls: type[_T], key: str) -> _T: ... @classmethod - def from_file(cls: Type[_T], __fobj: _IOBytes, key: str | None = ...) -> _T: ... + def from_file(cls: type[_T], __fobj: _IOBytes, key: str | None = ...) -> _T: ... @classmethod def clear_cache(cls, *, only_keys: Iterable[str] = ...) -> None: ... diff --git a/stubs/Deprecated/deprecated/classic.pyi b/stubs/Deprecated/deprecated/classic.pyi index b6f546235..160968742 100644 --- a/stubs/Deprecated/deprecated/classic.pyi +++ b/stubs/Deprecated/deprecated/classic.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Type, TypeVar, overload +from typing import Any, Callable, TypeVar, overload from typing_extensions import Literal _F = TypeVar("_F", bound=Callable[..., Any]) @@ -8,9 +8,9 @@ class ClassicAdapter: reason: str version: str action: _Actions | None - category: Type[Warning] + category: type[Warning] def __init__( - self, reason: str = ..., version: str = ..., action: _Actions | None = ..., category: Type[Warning] = ... + self, reason: str = ..., version: str = ..., action: _Actions | None = ..., category: type[Warning] = ... ) -> None: ... def get_deprecated_msg(self, wrapped: Callable[..., Any], instance: object) -> str: ... def __call__(self, wrapped: _F) -> Callable[[_F], _F]: ... @@ -19,5 +19,5 @@ class ClassicAdapter: def deprecated(__wrapped: _F) -> _F: ... @overload def deprecated( - reason: str = ..., *, version: str = ..., action: _Actions | None = ..., category: Type[Warning] | None = ... + reason: str = ..., *, version: str = ..., action: _Actions | None = ..., category: type[Warning] | None = ... ) -> Callable[[_F], _F]: ... diff --git a/stubs/Deprecated/deprecated/sphinx.pyi b/stubs/Deprecated/deprecated/sphinx.pyi index e5acd9406..7e6199645 100644 --- a/stubs/Deprecated/deprecated/sphinx.pyi +++ b/stubs/Deprecated/deprecated/sphinx.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Type, TypeVar +from typing import Any, Callable, TypeVar from typing_extensions import Literal from .classic import ClassicAdapter, _Actions @@ -10,14 +10,14 @@ class SphinxAdapter(ClassicAdapter): reason: str version: str action: _Actions | None - category: Type[Warning] + category: type[Warning] def __init__( self, directive: Literal["versionadded", "versionchanged", "deprecated"], reason: str = ..., version: str = ..., action: _Actions | None = ..., - category: Type[Warning] = ..., + category: type[Warning] = ..., ) -> None: ... def __call__(self, wrapped: _F) -> Callable[[_F], _F]: ... @@ -29,5 +29,5 @@ def deprecated( line_length: int = ..., *, action: _Actions | None = ..., - category: Type[Warning] | None = ..., + category: type[Warning] | None = ..., ) -> Callable[[_F], _F]: ... diff --git a/stubs/Pillow/PIL/ImageFilter.pyi b/stubs/Pillow/PIL/ImageFilter.pyi index e79914523..6ec69d53b 100644 --- a/stubs/Pillow/PIL/ImageFilter.pyi +++ b/stubs/Pillow/PIL/ImageFilter.pyi @@ -1,5 +1,5 @@ from _typeshed import Self -from typing import Any, Callable, Iterable, Sequence, Type +from typing import Any, Callable, Iterable, Sequence from typing_extensions import Literal from .Image import Image @@ -121,7 +121,7 @@ class Color3DLUT(MultibandFilter): ) -> None: ... @classmethod def generate( - cls: Type[Self], + cls: type[Self], size: int | tuple[int, int, int], callback: Callable[[float, float, float], Iterable[float]], channels: int = ..., diff --git a/stubs/PyMySQL/pymysql/connections.pyi b/stubs/PyMySQL/pymysql/connections.pyi index f357eb8b3..2ec680f83 100644 --- a/stubs/PyMySQL/pymysql/connections.pyi +++ b/stubs/PyMySQL/pymysql/connections.pyi @@ -1,5 +1,5 @@ from socket import socket as _socket -from typing import Any, AnyStr, Generic, Mapping, Type, TypeVar, overload +from typing import Any, AnyStr, Generic, Mapping, TypeVar, overload from .charset import charset_by_id as charset_by_id, charset_by_name as charset_by_name from .constants import CLIENT as CLIENT, COMMAND as COMMAND, FIELD_TYPE as FIELD_TYPE, SERVER_STATUS as SERVER_STATUS @@ -133,7 +133,7 @@ class Connection(Generic[_C]): conv=..., use_unicode: bool | None = ..., client_flag: int = ..., - cursorclass: Type[_C] = ..., # different between overloads + cursorclass: type[_C] = ..., # different between overloads init_command: Any | None = ..., connect_timeout: int | None = ..., ssl: Mapping[Any, Any] | None = ..., @@ -178,7 +178,7 @@ class Connection(Generic[_C]): @overload def cursor(self, cursor: None = ...) -> _C: ... @overload - def cursor(self, cursor: Type[_C2]) -> _C2: ... + def cursor(self, cursor: type[_C2]) -> _C2: ... def query(self, sql, unbuffered: bool = ...) -> int: ... def next_result(self, unbuffered: bool = ...) -> int: ... def affected_rows(self): ... diff --git a/stubs/PyMySQL/pymysql/converters.pyi b/stubs/PyMySQL/pymysql/converters.pyi index ee2e4ba89..f3d73fc3b 100644 --- a/stubs/PyMySQL/pymysql/converters.pyi +++ b/stubs/PyMySQL/pymysql/converters.pyi @@ -2,9 +2,9 @@ import datetime import time from collections.abc import Callable, Mapping, Sequence from decimal import Decimal -from typing import Any, Optional, Type, TypeVar +from typing import Any, Optional, TypeVar -_EscaperMapping = Optional[Mapping[Type[object], Callable[..., str]]] +_EscaperMapping = Optional[Mapping[type[object], Callable[..., str]]] _T = TypeVar("_T") def escape_item(val: object, charset: object, mapping: _EscaperMapping = ...) -> str: ... @@ -33,7 +33,7 @@ def through(x: _T) -> _T: ... convert_bit = through -encoders: dict[Type[object], Callable[..., str]] +encoders: dict[type[object], Callable[..., str]] decoders: dict[int, Callable[[str | bytes], Any]] -conversions: dict[Type[object] | int, Callable[..., Any]] +conversions: dict[type[object] | int, Callable[..., Any]] Thing2Literal = escape_str diff --git a/stubs/PyMySQL/pymysql/err.pyi b/stubs/PyMySQL/pymysql/err.pyi index 2a13b1d89..8aec38f53 100644 --- a/stubs/PyMySQL/pymysql/err.pyi +++ b/stubs/PyMySQL/pymysql/err.pyi @@ -1,5 +1,5 @@ import builtins -from typing import NoReturn, Type +from typing import NoReturn from .constants import ER as ER @@ -15,6 +15,6 @@ class InternalError(DatabaseError): ... class ProgrammingError(DatabaseError): ... class NotSupportedError(DatabaseError): ... -error_map: dict[int, Type[DatabaseError]] +error_map: dict[int, type[DatabaseError]] def raise_mysql_exception(data) -> NoReturn: ... diff --git a/stubs/PyYAML/yaml/__init__.pyi b/stubs/PyYAML/yaml/__init__.pyi index 3e202264e..69e2b8ec2 100644 --- a/stubs/PyYAML/yaml/__init__.pyi +++ b/stubs/PyYAML/yaml/__init__.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence -from typing import IO, Any, Pattern, Type, TypeVar, overload +from typing import IO, Any, Pattern, TypeVar, overload from . import resolver as resolver # Help mypy a bit; this is implied by loader and dumper from .constructor import BaseConstructor @@ -270,39 +270,39 @@ def add_implicit_resolver( tag: str, regexp: Pattern[str], first: Iterable[Any] | None = ..., - Loader: Type[BaseResolver] | None = ..., - Dumper: Type[BaseResolver] = ..., + Loader: type[BaseResolver] | None = ..., + Dumper: type[BaseResolver] = ..., ) -> None: ... def add_path_resolver( tag: str, path: Iterable[Any], - kind: Type[Any] | None = ..., - Loader: Type[BaseResolver] | None = ..., - Dumper: Type[BaseResolver] = ..., + kind: type[Any] | None = ..., + Loader: type[BaseResolver] | None = ..., + Dumper: type[BaseResolver] = ..., ) -> None: ... @overload def add_constructor( tag: str, constructor: Callable[[Loader | FullLoader | UnsafeLoader, Node], Any], Loader: None = ... ) -> None: ... @overload -def add_constructor(tag: str, constructor: Callable[[_Constructor, Node], Any], Loader: Type[_Constructor]) -> None: ... +def add_constructor(tag: str, constructor: Callable[[_Constructor, Node], Any], Loader: type[_Constructor]) -> None: ... @overload def add_multi_constructor( tag_prefix: str, multi_constructor: Callable[[Loader | FullLoader | UnsafeLoader, str, Node], Any], Loader: None = ... ) -> None: ... @overload def add_multi_constructor( - tag_prefix: str, multi_constructor: Callable[[_Constructor, str, Node], Any], Loader: Type[_Constructor] + tag_prefix: str, multi_constructor: Callable[[_Constructor, str, Node], Any], Loader: type[_Constructor] ) -> None: ... @overload -def add_representer(data_type: Type[_T], representer: Callable[[Dumper, _T], Node]) -> None: ... +def add_representer(data_type: type[_T], representer: Callable[[Dumper, _T], Node]) -> None: ... @overload -def add_representer(data_type: Type[_T], representer: Callable[[_Representer, _T], Node], Dumper: Type[_Representer]) -> None: ... +def add_representer(data_type: type[_T], representer: Callable[[_Representer, _T], Node], Dumper: type[_Representer]) -> None: ... @overload -def add_multi_representer(data_type: Type[_T], multi_representer: Callable[[Dumper, _T], Node]) -> None: ... +def add_multi_representer(data_type: type[_T], multi_representer: Callable[[Dumper, _T], Node]) -> None: ... @overload def add_multi_representer( - data_type: Type[_T], multi_representer: Callable[[_Representer, _T], Node], Dumper: Type[_Representer] + data_type: type[_T], multi_representer: Callable[[_Representer, _T], Node], Dumper: type[_Representer] ) -> None: ... class YAMLObjectMetaclass(type): diff --git a/stubs/PyYAML/yaml/representer.pyi b/stubs/PyYAML/yaml/representer.pyi index 298788a79..f9802d2df 100644 --- a/stubs/PyYAML/yaml/representer.pyi +++ b/stubs/PyYAML/yaml/representer.pyi @@ -2,7 +2,7 @@ import datetime from _typeshed import SupportsItems from collections.abc import Callable, Iterable, Mapping from types import BuiltinFunctionType, FunctionType, ModuleType -from typing import Any, ClassVar, NoReturn, Type, TypeVar +from typing import Any, ClassVar, NoReturn, TypeVar from yaml.error import YAMLError as YAMLError from yaml.nodes import MappingNode as MappingNode, Node as Node, ScalarNode as ScalarNode, SequenceNode as SequenceNode @@ -13,8 +13,8 @@ _R = TypeVar("_R", bound=BaseRepresenter) class RepresenterError(YAMLError): ... class BaseRepresenter: - yaml_representers: ClassVar[dict[Type[Any], Callable[[BaseRepresenter, Any], Node]]] - yaml_multi_representers: ClassVar[dict[Type[Any], Callable[[BaseRepresenter, Any], Node]]] + yaml_representers: ClassVar[dict[type[Any], Callable[[BaseRepresenter, Any], Node]]] + yaml_multi_representers: ClassVar[dict[type[Any], Callable[[BaseRepresenter, Any], Node]]] default_style: str | Any sort_keys: bool default_flow_style: bool @@ -25,9 +25,9 @@ class BaseRepresenter: def represent(self, data) -> None: ... def represent_data(self, data) -> Node: ... @classmethod - def add_representer(cls: Type[_R], data_type: Type[_T], representer: Callable[[_R, _T], Node]) -> None: ... + def add_representer(cls: type[_R], data_type: type[_T], representer: Callable[[_R, _T], Node]) -> None: ... @classmethod - def add_multi_representer(cls: Type[_R], data_type: Type[_T], representer: Callable[[_R, _T], Node]) -> None: ... + def add_multi_representer(cls: type[_R], data_type: type[_T], representer: Callable[[_R, _T], Node]) -> None: ... def represent_scalar(self, tag: str, value, style: str | None = ...) -> ScalarNode: ... def represent_sequence(self, tag: str, sequence: Iterable[Any], flow_style: bool | None = ...) -> SequenceNode: ... def represent_mapping( diff --git a/stubs/Pygments/pygments/formatters/__init__.pyi b/stubs/Pygments/pygments/formatters/__init__.pyi index b77043bb3..3e87595b7 100644 --- a/stubs/Pygments/pygments/formatters/__init__.pyi +++ b/stubs/Pygments/pygments/formatters/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Generator, Type +from typing import Generator from ..formatter import Formatter from .bbcode import BBCodeFormatter as BBCodeFormatter @@ -18,7 +18,7 @@ from .svg import SvgFormatter as SvgFormatter from .terminal import TerminalFormatter as TerminalFormatter from .terminal256 import Terminal256Formatter as Terminal256Formatter, TerminalTrueColorFormatter as TerminalTrueColorFormatter -def get_all_formatters() -> Generator[Type[Formatter], None, None]: ... +def get_all_formatters() -> Generator[type[Formatter], None, None]: ... def get_formatter_by_name(_alias, **options): ... def load_formatter_from_file(filename, formattername: str = ..., **options): ... def get_formatter_for_filename(fn, **options): ... diff --git a/stubs/SQLAlchemy/sqlalchemy/engine/default.pyi b/stubs/SQLAlchemy/sqlalchemy/engine/default.pyi index a461b5f5a..4f65bd5a2 100644 --- a/stubs/SQLAlchemy/sqlalchemy/engine/default.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/engine/default.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Type +from typing import Any, ClassVar from .. import types as sqltypes from ..util import memoized_property @@ -13,7 +13,7 @@ NO_CACHE_KEY: Any NO_DIALECT_SUPPORT: Any class DefaultDialect(interfaces.Dialect): - execution_ctx_cls: ClassVar[Type[interfaces.ExecutionContext]] + execution_ctx_cls: ClassVar[type[interfaces.ExecutionContext]] statement_compiler: Any ddl_compiler: Any type_compiler: Any diff --git a/stubs/SQLAlchemy/sqlalchemy/ext/mypy/plugin.pyi b/stubs/SQLAlchemy/sqlalchemy/ext/mypy/plugin.pyi index f89006949..8ec411585 100644 --- a/stubs/SQLAlchemy/sqlalchemy/ext/mypy/plugin.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/ext/mypy/plugin.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import Any, Type as TypingType +from typing import Any MypyFile = Any # from mypy.nodes AttributeContext = Any # from mypy.plugin @@ -17,4 +17,4 @@ class SQLAlchemyPlugin(Plugin): def get_attribute_hook(self, fullname: str) -> Callable[[AttributeContext], Type] | None: ... def get_additional_deps(self, file: MypyFile) -> list[tuple[int, str, int]]: ... -def plugin(version: str) -> TypingType[SQLAlchemyPlugin]: ... +def plugin(version: str) -> type[SQLAlchemyPlugin]: ... diff --git a/stubs/SQLAlchemy/sqlalchemy/ext/mypy/util.pyi b/stubs/SQLAlchemy/sqlalchemy/ext/mypy/util.pyi index 13a6f7e9c..73f16b6b2 100644 --- a/stubs/SQLAlchemy/sqlalchemy/ext/mypy/util.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/ext/mypy/util.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Iterator -from typing import Any, Type as TypingType, TypeVar, overload +from typing import Any, TypeVar, overload CallExpr = Any # from mypy.nodes Context = Any # from mypy.nodes @@ -42,7 +42,7 @@ def add_global(ctx: ClassDefContext | DynamicClassDefContext, module: str, symbo @overload def get_callexpr_kwarg(callexpr: CallExpr, name: str, *, expr_types: None = ...) -> CallExpr | NameExpr | None: ... @overload -def get_callexpr_kwarg(callexpr: CallExpr, name: str, *, expr_types: tuple[TypingType[_TArgType], ...]) -> _TArgType | None: ... +def get_callexpr_kwarg(callexpr: CallExpr, name: str, *, expr_types: tuple[type[_TArgType], ...]) -> _TArgType | None: ... def flatten_typechecking(stmts: Iterable[Statement]) -> Iterator[Statement]: ... def unbound_to_instance(api: SemanticAnalyzerPluginInterface, typ: Type) -> Type: ... def info_for_cls(cls, api: SemanticAnalyzerPluginInterface) -> TypeInfo | None: ... diff --git a/stubs/aiofiles/aiofiles/base.pyi b/stubs/aiofiles/aiofiles/base.pyi index 3859bc5ce..38c4ae102 100644 --- a/stubs/aiofiles/aiofiles/base.pyi +++ b/stubs/aiofiles/aiofiles/base.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import CodeType, FrameType, TracebackType, coroutine -from typing import Any, Coroutine, Generator, Generic, Iterator, Type, TypeVar +from typing import Any, Coroutine, Generator, Generic, Iterator, TypeVar _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) @@ -15,7 +15,7 @@ class AsyncBase(Generic[_T]): class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]): def __init__(self, coro: Coroutine[_T_co, _T_contra, _V_co]) -> None: ... def send(self, value: _T_contra) -> _T_co: ... - def throw(self, typ: Type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ...) -> _T_co: ... + def throw(self, typ: type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ...) -> _T_co: ... def close(self) -> None: ... @property def gi_frame(self) -> FrameType: ... @@ -30,5 +30,5 @@ class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]): async def __anext__(self) -> _V_co: ... async def __aenter__(self) -> _V_co: ... async def __aexit__( - 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: ... diff --git a/stubs/atomicwrites/atomicwrites/__init__.pyi b/stubs/atomicwrites/atomicwrites/__init__.pyi index 388ac2718..e1629cee4 100644 --- a/stubs/atomicwrites/atomicwrites/__init__.pyi +++ b/stubs/atomicwrites/atomicwrites/__init__.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import IO, Any, AnyStr, Callable, ContextManager, Text, Type +from typing import IO, Any, AnyStr, Callable, ContextManager, Text def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ... def move_atomic(src: AnyStr, dst: AnyStr) -> None: ... @@ -13,4 +13,4 @@ class AtomicWriter(object): def commit(self, f: IO[Any]) -> None: ... def rollback(self, f: IO[Any]) -> None: ... -def atomic_write(path: StrOrBytesPath, writer_cls: Type[AtomicWriter] = ..., **cls_kwargs: object) -> ContextManager[IO[Any]]: ... +def atomic_write(path: StrOrBytesPath, writer_cls: type[AtomicWriter] = ..., **cls_kwargs: object) -> ContextManager[IO[Any]]: ... diff --git a/stubs/beautifulsoup4/bs4/__init__.pyi b/stubs/beautifulsoup4/bs4/__init__.pyi index d975dfc8f..f779bd205 100644 --- a/stubs/beautifulsoup4/bs4/__init__.pyi +++ b/stubs/beautifulsoup4/bs4/__init__.pyi @@ -1,5 +1,5 @@ from _typeshed import Self, SupportsRead -from typing import Any, Sequence, Type +from typing import Any, Sequence from .builder import TreeBuilder from .element import PageElement, SoupStrainer, Tag @@ -23,11 +23,11 @@ class BeautifulSoup(Tag): self, markup: str | bytes | SupportsRead[str] | SupportsRead[bytes] = ..., features: str | Sequence[str] | None = ..., - builder: TreeBuilder | Type[TreeBuilder] | None = ..., + builder: TreeBuilder | type[TreeBuilder] | None = ..., parse_only: SoupStrainer | None = ..., from_encoding: str | None = ..., exclude_encodings: Sequence[str] | None = ..., - element_classes: dict[Type[PageElement], Type[Any]] | None = ..., + element_classes: dict[type[PageElement], type[Any]] | None = ..., **kwargs, ) -> None: ... def __copy__(self: Self) -> Self: ... diff --git a/stubs/beautifulsoup4/bs4/element.pyi b/stubs/beautifulsoup4/bs4/element.pyi index 576e3e6b4..9bffae817 100644 --- a/stubs/beautifulsoup4/bs4/element.pyi +++ b/stubs/beautifulsoup4/bs4/element.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from collections.abc import Iterator -from typing import Any, Callable, Generic, Iterable, Mapping, Pattern, Type, TypeVar, Union, overload +from typing import Any, Callable, Generic, Iterable, Mapping, Pattern, TypeVar, Union, overload from . import BeautifulSoup from .builder import TreeBuilder @@ -13,7 +13,7 @@ whitespace_re: Pattern[str] PYTHON_SPECIFIC_ENCODINGS: set[str] class NamespacedAttribute(str): - def __new__(cls: Type[Self], prefix: str, name: str | None = ..., namespace: str | None = ...) -> Self: ... + def __new__(cls: type[Self], prefix: str, name: str | None = ..., namespace: str | None = ...) -> Self: ... class AttributeValueWithCharsetSubstitution(str): ... @@ -53,7 +53,7 @@ class PageElement: previousSibling: PageElement | None @property def stripped_strings(self) -> Iterator[str]: ... - def get_text(self, separator: str = ..., strip: bool = ..., types: tuple[Type[NavigableString], ...] = ...) -> str: ... + def get_text(self, separator: str = ..., strip: bool = ..., types: tuple[type[NavigableString], ...] = ...) -> str: ... getText = get_text @property def text(self) -> str: ... @@ -182,7 +182,7 @@ class NavigableString(str, PageElement): PREFIX: str SUFFIX: str known_xml: bool | None - def __new__(cls: Type[Self], value: str | bytes) -> Self: ... + def __new__(cls: type[Self], value: str | bytes) -> Self: ... def __copy__(self: Self) -> Self: ... def __getnewargs__(self) -> tuple[str]: ... def output_ready(self, formatter: Formatter | str | None = ...) -> str: ... @@ -227,7 +227,7 @@ class Script(NavigableString): ... class TemplateString(NavigableString): ... class Tag(PageElement): - parser_class: Type[BeautifulSoup] | None + parser_class: type[BeautifulSoup] | None name: str namespace: str | None prefix: str | None @@ -256,9 +256,9 @@ class Tag(PageElement): can_be_empty_element: bool | None = ..., cdata_list_attributes: list[str] | None = ..., preserve_whitespace_tags: list[str] | None = ..., - interesting_string_types: Type[NavigableString] | tuple[Type[NavigableString], ...] | None = ..., + interesting_string_types: type[NavigableString] | tuple[type[NavigableString], ...] | None = ..., ) -> None: ... - parserClass: Type[BeautifulSoup] | None + parserClass: type[BeautifulSoup] | None def __copy__(self: Self) -> Self: ... @property def is_empty_element(self) -> bool: ... @@ -267,7 +267,7 @@ class Tag(PageElement): def string(self) -> str | None: ... @string.setter def string(self, string: str) -> None: ... - DEFAULT_INTERESTING_STRING_TYPES: tuple[Type[NavigableString], ...] + DEFAULT_INTERESTING_STRING_TYPES: tuple[type[NavigableString], ...] @property def strings(self) -> Iterable[str]: ... def decompose(self) -> None: ... diff --git a/stubs/boto/boto/kms/layer1.pyi b/stubs/boto/boto/kms/layer1.pyi index e27552336..5a7496ee3 100644 --- a/stubs/boto/boto/kms/layer1.pyi +++ b/stubs/boto/boto/kms/layer1.pyi @@ -1,4 +1,4 @@ -from typing import Any, Mapping, Type +from typing import Any, Mapping from boto.connection import AWSQueryConnection @@ -8,7 +8,7 @@ class KMSConnection(AWSQueryConnection): DefaultRegionEndpoint: str ServiceName: str TargetPrefix: str - ResponseError: Type[Exception] + ResponseError: type[Exception] region: Any def __init__(self, **kwargs) -> None: ... def create_alias(self, alias_name: str, target_key_id: str) -> dict[str, Any] | None: ... diff --git a/stubs/boto/boto/s3/__init__.pyi b/stubs/boto/boto/s3/__init__.pyi index fa747956e..c483c9cf4 100644 --- a/stubs/boto/boto/s3/__init__.pyi +++ b/stubs/boto/boto/s3/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Text, Type +from typing import Text from boto.connection import AWSAuthConnection from boto.regioninfo import RegionInfo @@ -10,7 +10,7 @@ class S3RegionInfo(RegionInfo): self, name: Text | None = ..., endpoint: str | None = ..., - connection_cls: Type[AWSAuthConnection] | None = ..., + connection_cls: type[AWSAuthConnection] | None = ..., **kw_params, ) -> S3Connection: ... diff --git a/stubs/boto/boto/s3/bucket.pyi b/stubs/boto/boto/s3/bucket.pyi index 741772ff3..196ba4d2e 100644 --- a/stubs/boto/boto/s3/bucket.pyi +++ b/stubs/boto/boto/s3/bucket.pyi @@ -1,4 +1,4 @@ -from typing import Any, Text, Type +from typing import Any, Text from .bucketlistresultset import BucketListResultSet from .connection import S3Connection @@ -19,8 +19,8 @@ class Bucket: MFADeleteRE: str name: Text connection: S3Connection - key_class: Type[Key] - def __init__(self, connection: S3Connection | None = ..., name: Text | None = ..., key_class: Type[Key] = ...) -> None: ... + key_class: type[Key] + def __init__(self, connection: S3Connection | None = ..., name: Text | None = ..., key_class: type[Key] = ...) -> None: ... def __iter__(self): ... def __contains__(self, key_name) -> bool: ... def startElement(self, name, attrs, connection): ... diff --git a/stubs/boto/boto/s3/connection.pyi b/stubs/boto/boto/s3/connection.pyi index 96b8d0de1..b0240e297 100644 --- a/stubs/boto/boto/s3/connection.pyi +++ b/stubs/boto/boto/s3/connection.pyi @@ -1,4 +1,4 @@ -from typing import Any, Text, Type +from typing import Any, Text from boto.connection import AWSAuthConnection from boto.exception import BotoClientError @@ -48,7 +48,7 @@ class S3Connection(AWSAuthConnection): DefaultCallingFormat: Any QueryString: str calling_format: Any - bucket_class: Type[Bucket] + bucket_class: type[Bucket] anon: Any def __init__( self, @@ -66,7 +66,7 @@ class S3Connection(AWSAuthConnection): calling_format: Any = ..., path: str = ..., provider: str = ..., - bucket_class: Type[Bucket] = ..., + bucket_class: type[Bucket] = ..., security_token: Any | None = ..., suppress_consec_slashes: bool = ..., anon: bool = ..., @@ -75,7 +75,7 @@ class S3Connection(AWSAuthConnection): ) -> None: ... def __iter__(self): ... def __contains__(self, bucket_name): ... - def set_bucket_class(self, bucket_class: Type[Bucket]) -> None: ... + def set_bucket_class(self, bucket_class: type[Bucket]) -> None: ... def build_post_policy(self, expiration_time, conditions): ... def build_post_form_args( self, diff --git a/stubs/boto/boto/utils.pyi b/stubs/boto/boto/utils.pyi index 91d2942f6..16ed18bd6 100644 --- a/stubs/boto/boto/utils.pyi +++ b/stubs/boto/boto/utils.pyi @@ -3,7 +3,7 @@ import logging.handlers import subprocess import sys import time -from typing import IO, Any, Callable, ContextManager, Iterable, Mapping, Sequence, Type, TypeVar +from typing import IO, Any, Callable, ContextManager, Iterable, Mapping, Sequence, TypeVar import boto.connection @@ -37,7 +37,7 @@ else: _Provider = Any # TODO replace this with boto.provider.Provider once stubs exist _LockType = Any # TODO replace this with _thread.LockType once stubs exist -JSONDecodeError: Type[ValueError] +JSONDecodeError: type[ValueError] qsa_of_interest: list[str] def unquote_v(nv: str) -> str | tuple[str, str]: ... @@ -71,7 +71,7 @@ LOCALE_LOCK: _LockType def setlocale(name: str | tuple[str, str]) -> ContextManager[str]: ... def get_ts(ts: time.struct_time | None = ...) -> str: ... def parse_ts(ts: str) -> datetime.datetime: ... -def find_class(module_name: str, class_name: str | None = ...) -> Type[Any] | None: ... +def find_class(module_name: str, class_name: str | None = ...) -> type[Any] | None: ... def update_dme(username: str, password: str, dme_id: str, ip_address: str) -> str: ... def fetch_file( uri: str, file: IO[str] | None = ..., username: str | None = ..., password: str | None = ... diff --git a/stubs/caldav/caldav/lib/error.pyi b/stubs/caldav/caldav/lib/error.pyi index b088bb8f2..66de08c19 100644 --- a/stubs/caldav/caldav/lib/error.pyi +++ b/stubs/caldav/caldav/lib/error.pyi @@ -1,5 +1,3 @@ -from typing import Type - def assert_(condition: object) -> None: ... ERR_FRAGMENT: str @@ -22,4 +20,4 @@ class NotFoundError(DAVError): ... class ConsistencyError(DAVError): ... class ResponseError(DAVError): ... -exception_by_method: dict[str, Type[DAVError]] +exception_by_method: dict[str, type[DAVError]] diff --git a/stubs/caldav/caldav/objects.pyi b/stubs/caldav/caldav/objects.pyi index 6f2f94ff1..1774ef8c0 100644 --- a/stubs/caldav/caldav/objects.pyi +++ b/stubs/caldav/caldav/objects.pyi @@ -1,7 +1,7 @@ import datetime from _typeshed import Self from collections.abc import Iterable, Iterator, Mapping -from typing import Any, Type, TypeVar, overload +from typing import Any, TypeVar, overload from typing_extensions import Literal from urllib.parse import ParseResult, SplitResult @@ -101,7 +101,7 @@ class Calendar(DAVObject): @overload def search(self, xml, comp_class: None = ...) -> list[CalendarObjectResource]: ... @overload - def search(self, xml, comp_class: Type[_CC]) -> list[_CC]: ... + def search(self, xml, comp_class: type[_CC]) -> list[_CC]: ... def freebusy_request(self, start: datetime.datetime, end: datetime.datetime) -> FreeBusy: ... def todos(self, sort_keys: Iterable[str] = ..., include_completed: bool = ..., sort_key: str | None = ...) -> list[Todo]: ... def event_by_url(self, href, data: Any | None = ...) -> Event: ... diff --git a/stubs/characteristic/characteristic/__init__.pyi b/stubs/characteristic/characteristic/__init__.pyi index 08056c3e6..d60ff1a35 100644 --- a/stubs/characteristic/characteristic/__init__.pyi +++ b/stubs/characteristic/characteristic/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr, Callable, Sequence, Type, TypeVar +from typing import Any, AnyStr, Callable, Sequence, TypeVar def with_repr(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... def with_cmp(attrs: Sequence[AnyStr | Attribute]) -> Callable[..., Any]: ... @@ -18,7 +18,7 @@ def attributes( apply_immutable: bool = ..., store_attributes: Callable[[type, Attribute], Any] | None = ..., **kw: dict[Any, Any] | None, -) -> Callable[[Type[_T]], Type[_T]]: ... +) -> Callable[[type[_T]], type[_T]]: ... class Attribute: def __init__( diff --git a/stubs/click-spinner/click_spinner/__init__.pyi b/stubs/click-spinner/click_spinner/__init__.pyi index 6ddb0e8f4..8abc4c7f7 100644 --- a/stubs/click-spinner/click_spinner/__init__.pyi +++ b/stubs/click-spinner/click_spinner/__init__.pyi @@ -1,6 +1,6 @@ import threading from types import TracebackType -from typing import Iterator, Protocol, Type +from typing import Iterator, Protocol from typing_extensions import Literal __version__: str @@ -24,7 +24,7 @@ class Spinner(object): def init_spin(self) -> None: ... def __enter__(self) -> Spinner: ... 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 ) -> Literal[False]: ... def spinner(beep: bool, disable: bool, force: bool, stream: _Stream) -> Spinner: ... diff --git a/stubs/croniter/croniter.pyi b/stubs/croniter/croniter.pyi index 1c864f5cc..ea8c5103b 100644 --- a/stubs/croniter/croniter.pyi +++ b/stubs/croniter/croniter.pyi @@ -1,8 +1,8 @@ import datetime -from typing import Any, Iterator, Text, Type, TypeVar, Union +from typing import Any, Iterator, Text, TypeVar, Union from typing_extensions import Literal -_RetType = Union[Type[float], Type[datetime.datetime]] +_RetType = Union[type[float], type[datetime.datetime]] _SelfT = TypeVar("_SelfT", bound=croniter) class CroniterError(ValueError): ... @@ -74,5 +74,5 @@ def croniter_range( ret_type: _RetType | None = ..., day_or: bool = ..., exclude_ends: bool = ..., - _croniter: Type[croniter] | None = ..., + _croniter: type[croniter] | None = ..., ) -> Iterator[Any]: ... diff --git a/stubs/cryptography/cryptography/x509/__init__.pyi b/stubs/cryptography/cryptography/x509/__init__.pyi index be3b7bdab..7c58e2a7e 100644 --- a/stubs/cryptography/cryptography/x509/__init__.pyi +++ b/stubs/cryptography/cryptography/x509/__init__.pyi @@ -2,7 +2,7 @@ import datetime from abc import ABCMeta, abstractmethod from enum import Enum from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network -from typing import Any, ClassVar, Generator, Generic, Iterable, Sequence, Text, Type, TypeVar +from typing import Any, ClassVar, Generator, Generic, Iterable, Sequence, Text, TypeVar from cryptography.hazmat.backends.interfaces import X509Backend from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey @@ -293,7 +293,7 @@ class Extensions(object): def __init__(self, general_names: list[Extension[Any]]) -> None: ... def __iter__(self) -> Generator[Extension[Any], None, None]: ... def get_extension_for_oid(self, oid: ObjectIdentifier) -> Extension[Any]: ... - def get_extension_for_class(self, extclass: Type[_T]) -> Extension[_T]: ... + def get_extension_for_class(self, extclass: type[_T]) -> Extension[_T]: ... class DuplicateExtension(Exception): oid: ObjectIdentifier @@ -306,12 +306,12 @@ class ExtensionNotFound(Exception): class IssuerAlternativeName(ExtensionType): def __init__(self, general_names: list[GeneralName]) -> None: ... def __iter__(self) -> Generator[GeneralName, None, None]: ... - def get_values_for_type(self, type: Type[GeneralName]) -> list[Any]: ... + def get_values_for_type(self, type: type[GeneralName]) -> list[Any]: ... class SubjectAlternativeName(ExtensionType): def __init__(self, general_names: list[GeneralName]) -> None: ... def __iter__(self) -> Generator[GeneralName, None, None]: ... - def get_values_for_type(self, type: Type[GeneralName]) -> list[Any]: ... + def get_values_for_type(self, type: type[GeneralName]) -> list[Any]: ... class AuthorityKeyIdentifier(ExtensionType): @property diff --git a/stubs/dataclasses/dataclasses.pyi b/stubs/dataclasses/dataclasses.pyi index 922b26c18..8f76c6be1 100644 --- a/stubs/dataclasses/dataclasses.pyi +++ b/stubs/dataclasses/dataclasses.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Generic, Iterable, Mapping, Type, TypeVar, overload +from typing import Any, Callable, Generic, Iterable, Mapping, TypeVar, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -19,17 +19,17 @@ def astuple(obj: Any) -> tuple[Any, ...]: ... @overload def astuple(obj: Any, *, tuple_factory: Callable[[list[Any]], _T]) -> _T: ... @overload -def dataclass(_cls: Type[_T]) -> Type[_T]: ... +def dataclass(_cls: type[_T]) -> type[_T]: ... @overload -def dataclass(_cls: None) -> Callable[[Type[_T]], Type[_T]]: ... +def dataclass(_cls: None) -> Callable[[type[_T]], type[_T]]: ... @overload def dataclass( *, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ... -) -> Callable[[Type[_T]], Type[_T]]: ... +) -> Callable[[type[_T]], type[_T]]: ... class Field(Generic[_T]): name: str - type: Type[_T] + type: type[_T] default: _T default_factory: Callable[[], _T] repr: bool diff --git a/stubs/dateparser/dateparser/date.pyi b/stubs/dateparser/dateparser/date.pyi index cc5118dce..468a1fb31 100644 --- a/stubs/dateparser/dateparser/date.pyi +++ b/stubs/dateparser/dateparser/date.pyi @@ -2,7 +2,7 @@ import collections import sys from _typeshed import Self as Self from datetime import datetime -from typing import ClassVar, Iterable, Iterator, Type, overload +from typing import ClassVar, Iterable, Iterator, overload from dateparser import _Settings from dateparser.conf import Settings @@ -107,4 +107,4 @@ class DateDataParser: def _get_applicable_locales(self, date_string: str) -> Iterator[Locale]: ... def _is_applicable_locale(self, locale: Locale, date_string: str) -> bool: ... @classmethod - def _get_locale_loader(cls: Type[DateDataParser]) -> LocaleDataLoader: ... + def _get_locale_loader(cls: type[DateDataParser]) -> LocaleDataLoader: ... diff --git a/stubs/docutils/docutils/frontend.pyi b/stubs/docutils/docutils/frontend.pyi index 0ec658629..e71907471 100644 --- a/stubs/docutils/docutils/frontend.pyi +++ b/stubs/docutils/docutils/frontend.pyi @@ -1,7 +1,7 @@ import optparse from collections.abc import Iterable, Mapping from configparser import RawConfigParser -from typing import Any, ClassVar, Type +from typing import Any, ClassVar from docutils import SettingsSpec from docutils.parsers import Parser @@ -64,7 +64,7 @@ class OptionParser(optparse.OptionParser, SettingsSpec): version_template: ClassVar[str] def __init__( self, - components: Iterable[Type[Parser]] = ..., + components: Iterable[type[Parser]] = ..., defaults: Mapping[str, Any] | None = ..., read_config_files: bool | None = ..., *args, diff --git a/stubs/docutils/docutils/parsers/__init__.pyi b/stubs/docutils/docutils/parsers/__init__.pyi index a77c18373..75fd95c89 100644 --- a/stubs/docutils/docutils/parsers/__init__.pyi +++ b/stubs/docutils/docutils/parsers/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Type +from typing import Any, ClassVar from docutils import Component @@ -13,4 +13,4 @@ class Parser(Component): _parser_aliases: dict[str, str] -def get_parser_class(parser_name: str) -> Type[Parser]: ... +def get_parser_class(parser_name: str) -> type[Parser]: ... diff --git a/stubs/entrypoints/entrypoints.pyi b/stubs/entrypoints/entrypoints.pyi index 8b64db4c7..11a716f30 100644 --- a/stubs/entrypoints/entrypoints.pyi +++ b/stubs/entrypoints/entrypoints.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import Self -from typing import Any, Iterator, Sequence, Text, Type +from typing import Any, Iterator, Sequence, Text if sys.version_info >= (3, 0): from configparser import ConfigParser @@ -42,7 +42,7 @@ class EntryPoint: ) -> None: ... def load(self) -> Any: ... @classmethod - def from_string(cls: Type[Self], epstr: Text, name: Text, distro: Distribution | None = ...) -> Self: ... + def from_string(cls: type[Self], epstr: Text, name: Text, distro: Distribution | None = ...) -> Self: ... class Distribution: name: Text diff --git a/stubs/filelock/filelock/__init__.pyi b/stubs/filelock/filelock/__init__.pyi index e10860f89..2cb3fe966 100644 --- a/stubs/filelock/filelock/__init__.pyi +++ b/stubs/filelock/filelock/__init__.pyi @@ -1,6 +1,5 @@ import sys from types import TracebackType -from typing import Type class Timeout(TimeoutError): def __init__(self, lock_file: str) -> None: ... @@ -10,7 +9,7 @@ class _Acquire_ReturnProxy: def __init__(self, lock: str) -> None: ... def __enter__(self) -> str: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, traceback: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, traceback: TracebackType | None ) -> None: ... class BaseFileLock: @@ -27,7 +26,7 @@ class BaseFileLock: def release(self, force: bool = ...) -> None: ... def __enter__(self) -> BaseFileLock: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, traceback: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, traceback: TracebackType | None ) -> None: ... def __del__(self) -> None: ... diff --git a/stubs/flake8-2020/flake8_2020.pyi b/stubs/flake8-2020/flake8_2020.pyi index 3577b66a6..b46c3d5ed 100644 --- a/stubs/flake8-2020/flake8_2020.pyi +++ b/stubs/flake8-2020/flake8_2020.pyi @@ -3,12 +3,12 @@ # Therefore typeshed is the best place. import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Generator class Plugin: name: ClassVar[str] version: ClassVar[str] def __init__(self, tree: ast.AST) -> None: ... - def run(self) -> Generator[tuple[int, int, str, Type[Any]], None, None]: ... + def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... def __getattr__(name: str) -> Any: ... # incomplete (other attributes are normally not accessed) diff --git a/stubs/flake8-builtins/flake8_builtins.pyi b/stubs/flake8-builtins/flake8_builtins.pyi index e5a3d89c5..904be75d3 100644 --- a/stubs/flake8-builtins/flake8_builtins.pyi +++ b/stubs/flake8-builtins/flake8_builtins.pyi @@ -1,10 +1,10 @@ import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Generator class BuiltinsChecker: name: ClassVar[str] version: ClassVar[str] def __init__(self, tree: ast.AST, filename: str) -> None: ... - def run(self) -> Generator[tuple[int, int, str, Type[Any]], None, None]: ... + def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... def __getattr__(name: str) -> Any: ... # incomplete (other attributes are normally not accessed) diff --git a/stubs/flake8-docstrings/flake8_docstrings.pyi b/stubs/flake8-docstrings/flake8_docstrings.pyi index bd8621cfe..80c252903 100644 --- a/stubs/flake8-docstrings/flake8_docstrings.pyi +++ b/stubs/flake8-docstrings/flake8_docstrings.pyi @@ -1,6 +1,6 @@ import argparse import ast -from typing import Any, ClassVar, Generator, Iterable, Type +from typing import Any, ClassVar, Generator, Iterable class pep257Checker: name: ClassVar[str] @@ -14,6 +14,6 @@ class pep257Checker: def add_options(cls, parser: Any) -> None: ... @classmethod def parse_options(cls, options: argparse.Namespace) -> None: ... - def run(self) -> Generator[tuple[int, int, str, Type[Any]], None, None]: ... + def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... def __getattr__(name: str) -> Any: ... # incomplete diff --git a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi index 11f052fdb..25f910fc3 100644 --- a/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi +++ b/stubs/flake8-plugin-utils/flake8_plugin_utils/plugin.pyi @@ -1,8 +1,8 @@ import argparse import ast -from typing import Any, Generic, Iterable, Iterator, Type, TypeVar +from typing import Any, Generic, Iterable, Iterator, TypeVar -FLAKE8_ERROR = tuple[int, int, str, Type[Any]] +FLAKE8_ERROR = tuple[int, int, str, type[Any]] TConfig = TypeVar("TConfig") # noqa: Y001 class Error: @@ -19,12 +19,12 @@ class Visitor(ast.NodeVisitor, Generic[TConfig]): def __init__(self, config: TConfig | None = ...) -> None: ... @property def config(self) -> TConfig: ... - def error_from_node(self, error: Type[Error], node: ast.AST, **kwargs: Any) -> None: ... + def error_from_node(self, error: type[Error], node: ast.AST, **kwargs: Any) -> None: ... class Plugin(Generic[TConfig]): name: str version: str - visitors: list[Type[Visitor[TConfig]]] + visitors: list[type[Visitor[TConfig]]] config: TConfig def __init__(self, tree: ast.AST) -> None: ... def run(self) -> Iterable[FLAKE8_ERROR]: ... diff --git a/stubs/flake8-plugin-utils/flake8_plugin_utils/utils/assertions.pyi b/stubs/flake8-plugin-utils/flake8_plugin_utils/utils/assertions.pyi index 2bd61dd84..d030a527f 100644 --- a/stubs/flake8-plugin-utils/flake8_plugin_utils/utils/assertions.pyi +++ b/stubs/flake8-plugin-utils/flake8_plugin_utils/utils/assertions.pyi @@ -1,8 +1,8 @@ -from typing import Any, Type +from typing import Any from ..plugin import Error as Error, TConfig as TConfig, Visitor as Visitor def assert_error( - visitor_cls: Type[Visitor[TConfig]], src: str, expected: Type[Error], config: TConfig | None = ..., **kwargs: Any + visitor_cls: type[Visitor[TConfig]], src: str, expected: type[Error], config: TConfig | None = ..., **kwargs: Any ) -> None: ... -def assert_not_error(visitor_cls: Type[Visitor[TConfig]], src: str, config: TConfig | None = ...) -> None: ... +def assert_not_error(visitor_cls: type[Visitor[TConfig]], src: str, config: TConfig | None = ...) -> None: ... diff --git a/stubs/flake8-simplify/flake8_simplify.pyi b/stubs/flake8-simplify/flake8_simplify.pyi index 0d5e35b60..7296c8a25 100644 --- a/stubs/flake8-simplify/flake8_simplify.pyi +++ b/stubs/flake8-simplify/flake8_simplify.pyi @@ -1,8 +1,8 @@ import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Generator class Plugin: name: ClassVar[str] version: ClassVar[str] def __init__(self, tree: ast.AST) -> None: ... - def run(self) -> Generator[tuple[int, int, str, Type[Any]], None, None]: ... + def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... diff --git a/stubs/flake8-typing-imports/flake8_typing_imports.pyi b/stubs/flake8-typing-imports/flake8_typing_imports.pyi index 045859668..0b3fe50a1 100644 --- a/stubs/flake8-typing-imports/flake8_typing_imports.pyi +++ b/stubs/flake8-typing-imports/flake8_typing_imports.pyi @@ -1,6 +1,6 @@ import argparse import ast -from typing import Any, ClassVar, Generator, Type +from typing import Any, ClassVar, Generator class Plugin: name: ClassVar[str] @@ -10,6 +10,6 @@ class Plugin: @classmethod def parse_options(cls, options: argparse.Namespace) -> None: ... def __init__(self, tree: ast.AST) -> None: ... - def run(self) -> Generator[tuple[int, int, str, Type[Any]], None, None]: ... + def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... def __getattr__(name: str) -> Any: ... # incomplete (other attributes are normally not accessed) diff --git a/stubs/freezegun/freezegun/api.pyi b/stubs/freezegun/freezegun/api.pyi index 3ad350e2d..183443ede 100644 --- a/stubs/freezegun/freezegun/api.pyi +++ b/stubs/freezegun/freezegun/api.pyi @@ -1,7 +1,7 @@ from collections.abc import Awaitable, Callable, Iterator, Sequence from datetime import date, datetime, timedelta from numbers import Real -from typing import Any, Type, TypeVar, Union, overload +from typing import Any, TypeVar, Union, overload _T = TypeVar("_T") _Freezable = Union[str, datetime, date, timedelta] @@ -35,7 +35,7 @@ class _freeze_time: auto_tick_seconds: float, ) -> None: ... @overload - def __call__(self, func: Type[_T]) -> Type[_T]: ... + def __call__(self, func: type[_T]) -> type[_T]: ... @overload def __call__(self, func: Callable[..., Awaitable[_T]]) -> Callable[..., Awaitable[_T]]: ... @overload @@ -44,7 +44,7 @@ class _freeze_time: def __exit__(self, *args: Any) -> None: ... def start(self) -> Any: ... def stop(self) -> None: ... - def decorate_class(self, klass: Type[_T]) -> _T: ... + def decorate_class(self, klass: type[_T]) -> _T: ... def decorate_coroutine(self, coroutine: _T) -> _T: ... def decorate_callable(self, func: Callable[..., _T]) -> Callable[..., _T]: ... diff --git a/stubs/frozendict/frozendict.pyi b/stubs/frozendict/frozendict.pyi index 10c78c8e6..238c665e7 100644 --- a/stubs/frozendict/frozendict.pyi +++ b/stubs/frozendict/frozendict.pyi @@ -1,5 +1,5 @@ import collections -from typing import Any, Generic, Iterable, Iterator, Mapping, Type, TypeVar, overload +from typing import Any, Generic, Iterable, Iterator, Mapping, TypeVar, overload _S = TypeVar("_S") _KT = TypeVar("_KT") @@ -7,7 +7,7 @@ _VT = TypeVar("_VT") class frozendict(Mapping[_KT, _VT], Generic[_KT, _VT]): - dict_cls: Type[dict[Any, Any]] = ... + dict_cls: type[dict[Any, Any]] = ... @overload def __init__(self, **kwargs: _VT) -> None: ... @overload @@ -24,4 +24,4 @@ class frozendict(Mapping[_KT, _VT], Generic[_KT, _VT]): class FrozenOrderedDict(frozendict[_KT, _VT]): - dict_cls: Type[collections.OrderedDict[Any, Any]] = ... + dict_cls: type[collections.OrderedDict[Any, Any]] = ... diff --git a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi index 08d663f96..48093d106 100644 --- a/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi +++ b/stubs/google-cloud-ndb/google/cloud/ndb/model.pyi @@ -1,6 +1,6 @@ import datetime from collections.abc import Iterable, Sequence -from typing import Callable, NoReturn, Type +from typing import Callable, NoReturn from typing_extensions import Literal from google.cloud.ndb import exceptions, key as key_module, query as query_module, tasklets as tasklets_module @@ -96,16 +96,16 @@ class Property(ModelAttribute): class ModelKey(Property): def __init__(self) -> None: ... - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> key_module.Key | list[key_module.Key] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> key_module.Key | list[key_module.Key] | None: ... class BooleanProperty(Property): - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> bool | list[bool] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> bool | list[bool] | None: ... class IntegerProperty(Property): - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> int | list[int] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> int | list[int] | None: ... class FloatProperty(Property): - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> float | list[float] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> float | list[float] | None: ... class _CompressedValue(bytes): z_val: bytes = ... @@ -127,7 +127,7 @@ class BlobProperty(Property): verbose_name: str | None = ..., write_empty_list: bool | None = ..., ) -> None: ... - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> bytes | list[bytes] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> bytes | list[bytes] | None: ... class CompressedTextProperty(BlobProperty): def __init__(self, *args, **kwargs) -> None: ... @@ -135,7 +135,7 @@ class CompressedTextProperty(BlobProperty): class TextProperty(Property): def __new__(cls, *args, **kwargs): ... def __init__(self, *args, **kwargs) -> None: ... - def __get__(self, entity: Model, unused_cls: Type[Model] | None = ...) -> str | list[str] | None: ... + def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> str | list[str] | None: ... class StringProperty(TextProperty): def __init__(self, *args, **kwargs) -> None: ... @@ -189,7 +189,7 @@ class KeyProperty(Property): def __init__( self, name: str | None = ..., - kind: Type[Model] | str | None = ..., + kind: type[Model] | str | None = ..., indexed: bool | None = ..., repeated: bool | None = ..., required: bool | None = ..., @@ -228,7 +228,7 @@ class StructuredProperty(Property): def IN(self, value: Iterable[object]) -> query_module.DisjunctionNode | query_module.FalseNode: ... class LocalStructuredProperty(BlobProperty): - def __init__(self, model_class: Type[Model], **kwargs) -> None: ... + def __init__(self, model_class: type[Model], **kwargs) -> None: ... class GenericProperty(Property): def __init__(self, name: str | None = ..., compressed: bool = ..., **kwargs) -> None: ... @@ -252,14 +252,14 @@ class Model(_NotEqualMixin, metaclass=MetaModel): def __hash__(self) -> NoReturn: ... def __eq__(self, other: object) -> bool: ... @classmethod - def gql(cls: Type[Model], query_string: str, *args, **kwargs) -> query_module.Query: ... + def gql(cls: type[Model], query_string: str, *args, **kwargs) -> query_module.Query: ... def put(self, **kwargs): ... def put_async(self, **kwargs) -> tasklets_module.Future: ... @classmethod - def query(cls: Type[Model], *args, **kwargs) -> query_module.Query: ... + def query(cls: type[Model], *args, **kwargs) -> query_module.Query: ... @classmethod def allocate_ids( - cls: Type[Model], + cls: type[Model], size: int | None = ..., max: int | None = ..., parent: key_module.Key | None = ..., @@ -278,7 +278,7 @@ class Model(_NotEqualMixin, metaclass=MetaModel): ) -> tuple[key_module.Key, key_module.Key]: ... @classmethod def allocate_ids_async( - cls: Type[Model], + cls: type[Model], size: int | None = ..., max: int | None = ..., parent: key_module.Key | None = ..., @@ -297,7 +297,7 @@ class Model(_NotEqualMixin, metaclass=MetaModel): ) -> tasklets_module.Future: ... @classmethod def get_by_id( - cls: Type[Model], + cls: type[Model], id: int | str | None, parent: key_module.Key | None = ..., namespace: str | None = ..., @@ -321,7 +321,7 @@ class Model(_NotEqualMixin, metaclass=MetaModel): ) -> tasklets_module.Future: ... @classmethod def get_by_id_async( - cls: Type[Model], + cls: type[Model], id: int | str, parent: key_module.Key | None = ..., namespace: str | None = ..., @@ -345,7 +345,7 @@ class Model(_NotEqualMixin, metaclass=MetaModel): ) -> Model | None: ... @classmethod def get_or_insert( - cls: Type[Model], + cls: type[Model], name: str, parent: key_module.Key | None = ..., namespace: str | None = ..., @@ -370,7 +370,7 @@ class Model(_NotEqualMixin, metaclass=MetaModel): ) -> Model: ... @classmethod def get_or_insert_async( - cls: Type[Model], + cls: type[Model], name: str, parent: key_module.Key | None = ..., namespace: str | None = ..., @@ -407,7 +407,7 @@ class Expando(Model): def __delattr__(self, name: str) -> None: ... def get_multi_async( - keys: Sequence[Type[key_module.Key]], + keys: Sequence[type[key_module.Key]], read_consistency: Literal["EVENTUAL"] | None = ..., read_policy: Literal["EVENTUAL"] | None = ..., transaction: bytes | None = ..., @@ -423,9 +423,9 @@ def get_multi_async( max_memcache_items: int | None = ..., force_writes: bool | None = ..., _options: object | None = ..., -) -> list[Type[tasklets_module.Future]]: ... +) -> list[type[tasklets_module.Future]]: ... def get_multi( - keys: Sequence[Type[key_module.Key]], + keys: Sequence[type[key_module.Key]], read_consistency: Literal["EVENTUAL"] | None = ..., read_policy: Literal["EVENTUAL"] | None = ..., transaction: bytes | None = ..., @@ -441,9 +441,9 @@ def get_multi( max_memcache_items: int | None = ..., force_writes: bool | None = ..., _options: object | None = ..., -) -> list[Type[Model] | None]: ... +) -> list[type[Model] | None]: ... def put_multi_async( - entities: list[Type[Model]], + entities: list[type[Model]], retries: int | None = ..., timeout: float | None = ..., deadline: float | None = ..., diff --git a/stubs/hdbcli/hdbcli/dbapi.pyi b/stubs/hdbcli/hdbcli/dbapi.pyi index 61618b9da..4fe4abfd5 100644 --- a/stubs/hdbcli/hdbcli/dbapi.pyi +++ b/stubs/hdbcli/hdbcli/dbapi.pyi @@ -1,7 +1,7 @@ import decimal from _typeshed import ReadableBuffer from datetime import date, datetime, time -from typing import Any, Sequence, Type, overload +from typing import Any, Sequence, overload from typing_extensions import Literal from .resultrow import ResultRow @@ -108,8 +108,8 @@ def Binary(data: ReadableBuffer) -> memoryview: ... Decimal = decimal.Decimal -NUMBER: Type[int] | Type[float] | Type[complex] -DATETIME: Type[date] | Type[time] | Type[datetime] +NUMBER: type[int] | type[float] | type[complex] +DATETIME: type[date] | type[time] | type[datetime] STRING = str BINARY = memoryview ROWID = int diff --git a/stubs/ldap3/ldap3/__init__.pyi b/stubs/ldap3/ldap3/__init__.pyi index 2336956e8..4e9d2efd2 100644 --- a/stubs/ldap3/ldap3/__init__.pyi +++ b/stubs/ldap3/ldap3/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Type +from typing import Any from typing_extensions import Literal from .abstract.attrDef import AttrDef as AttrDef @@ -98,7 +98,7 @@ HASHED_SALTED_SHA384: Literal["SALTED_SHA384"] HASHED_SALTED_SHA512: Literal["SALTED_SHA512"] HASHED_SALTED_MD5: Literal["SALTED_MD5"] -NUMERIC_TYPES: tuple[Type[Any], ...] -INTEGER_TYPES: tuple[Type[Any], ...] -STRING_TYPES: tuple[Type[Any], ...] -SEQUENCE_TYPES: tuple[Type[Any], ...] +NUMERIC_TYPES: tuple[type[Any], ...] +INTEGER_TYPES: tuple[type[Any], ...] +STRING_TYPES: tuple[type[Any], ...] +SEQUENCE_TYPES: tuple[type[Any], ...] diff --git a/stubs/ldap3/ldap3/core/connection.pyi b/stubs/ldap3/ldap3/core/connection.pyi index 2b21d779b..339bdd4c5 100644 --- a/stubs/ldap3/ldap3/core/connection.pyi +++ b/stubs/ldap3/ldap3/core/connection.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Any, Type +from typing import Any from typing_extensions import Literal from .server import Server @@ -101,7 +101,7 @@ class Connection: def usage(self): ... 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 ) -> Literal[False] | None: ... def bind(self, read_server_info: bool = ..., controls: Any | None = ...): ... def rebind( diff --git a/stubs/ldap3/ldap3/core/exceptions.pyi b/stubs/ldap3/ldap3/core/exceptions.pyi index 9e1cc8138..b7b3d6b30 100644 --- a/stubs/ldap3/ldap3/core/exceptions.pyi +++ b/stubs/ldap3/ldap3/core/exceptions.pyi @@ -1,5 +1,5 @@ import socket -from typing import Any, Type, TypeVar +from typing import Any, TypeVar _T = TypeVar("_T") @@ -7,7 +7,7 @@ class LDAPException(Exception): ... class LDAPOperationResult(LDAPException): def __new__( - cls: Type[_T], + cls: type[_T], result: Any | None = ..., description: Any | None = ..., dn: Any | None = ..., diff --git a/stubs/mock/mock/mock.pyi b/stubs/mock/mock/mock.pyi index 0765ea745..43e158413 100644 --- a/stubs/mock/mock/mock.pyi +++ b/stubs/mock/mock/mock.pyi @@ -1,9 +1,9 @@ from collections.abc import Callable, Mapping, Sequence -from typing import Any, Generic, Type, TypeVar, overload +from typing import Any, Generic, TypeVar, overload _F = TypeVar("_F", bound=Callable[..., Any]) _T = TypeVar("_T") -_TT = TypeVar("_TT", bound=Type[Any]) +_TT = TypeVar("_TT", bound=type[Any]) _R = TypeVar("_R") __all__ = ( @@ -62,10 +62,10 @@ class NonCallableMock(Base, Any): def __new__(__cls, *args: Any, **kw: Any) -> NonCallableMock: ... def __init__( self, - spec: list[str] | object | Type[object] | None = ..., + spec: list[str] | object | type[object] | None = ..., wraps: Any | None = ..., name: str | None = ..., - spec_set: list[str] | object | Type[object] | None = ..., + spec_set: list[str] | object | type[object] | None = ..., parent: NonCallableMock | None = ..., _spec_state: Any | None = ..., _new_name: str = ..., @@ -174,7 +174,7 @@ class _patch_dict: class _patcher: TEST_PREFIX: str - dict: Type[_patch_dict] + dict: type[_patch_dict] @overload def __call__( # type: ignore[misc] self, diff --git a/stubs/mypy-extensions/mypy_extensions.pyi b/stubs/mypy-extensions/mypy_extensions.pyi index dd182c485..f5ede45ac 100644 --- a/stubs/mypy-extensions/mypy_extensions.pyi +++ b/stubs/mypy-extensions/mypy_extensions.pyi @@ -1,6 +1,6 @@ import abc import sys -from typing import Any, Callable, Generic, ItemsView, KeysView, Mapping, Type, TypeVar, ValuesView +from typing import Any, Callable, Generic, ItemsView, KeysView, Mapping, TypeVar, ValuesView _T = TypeVar("_T") _U = TypeVar("_U") @@ -25,7 +25,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta): def viewvalues(self) -> ValuesView[object]: ... def __delitem__(self, k: NoReturn) -> None: ... -def TypedDict(typename: str, fields: dict[str, Type[Any]], total: bool = ...) -> Type[dict[str, Any]]: ... +def TypedDict(typename: str, fields: dict[str, type[Any]], total: bool = ...) -> type[dict[str, Any]]: ... def Arg(type: _T = ..., name: str | None = ...) -> _T: ... def DefaultArg(type: _T = ..., name: str | None = ...) -> _T: ... def NamedArg(type: _T = ..., name: str | None = ...) -> _T: ... diff --git a/stubs/opentracing/opentracing/scope.pyi b/stubs/opentracing/opentracing/scope.pyi index ec2964d5b..3ab00d387 100644 --- a/stubs/opentracing/opentracing/scope.pyi +++ b/stubs/opentracing/opentracing/scope.pyi @@ -1,5 +1,4 @@ from types import TracebackType -from typing import Type from .scope_manager import ScopeManager from .span import Span @@ -13,5 +12,5 @@ class Scope: def close(self) -> None: ... def __enter__(self) -> Scope: ... 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: ... diff --git a/stubs/opentracing/opentracing/span.pyi b/stubs/opentracing/opentracing/span.pyi index 847f16bba..3f9685adb 100644 --- a/stubs/opentracing/opentracing/span.pyi +++ b/stubs/opentracing/opentracing/span.pyi @@ -1,6 +1,6 @@ from _typeshed import Self from types import TracebackType -from typing import Any, Type +from typing import Any from .tracer import Tracer @@ -23,7 +23,7 @@ class Span: def get_baggage_item(self, key: str) -> str | 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 log_event(self: Self, event: Any, payload: Any | None = ...) -> Self: ... def log(self: Self, **kwargs: Any) -> Self: ... diff --git a/stubs/paramiko/paramiko/_winapi.pyi b/stubs/paramiko/paramiko/_winapi.pyi index 92517ba6c..1a302c03f 100644 --- a/stubs/paramiko/paramiko/_winapi.pyi +++ b/stubs/paramiko/paramiko/_winapi.pyi @@ -2,7 +2,7 @@ import builtins import ctypes import sys from types import TracebackType -from typing import Any, Type, TypeVar +from typing import Any, TypeVar if sys.platform == "win32": @@ -37,7 +37,7 @@ if sys.platform == "win32": def write(self, msg: bytes) -> None: ... def read(self, n: int) -> bytes: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, tb: TracebackType | None + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, tb: TracebackType | None ) -> None: ... READ_CONTROL: int STANDARD_RIGHTS_REQUIRED: int diff --git a/stubs/paramiko/paramiko/client.pyi b/stubs/paramiko/paramiko/client.pyi index f088dbe53..4bbf3c2dc 100644 --- a/stubs/paramiko/paramiko/client.pyi +++ b/stubs/paramiko/paramiko/client.pyi @@ -1,5 +1,5 @@ from socket import socket -from typing import Iterable, Mapping, NoReturn, Type +from typing import Iterable, Mapping, NoReturn from paramiko.channel import Channel, ChannelFile, ChannelStderrFile, ChannelStdinFile from paramiko.hostkeys import HostKeys @@ -15,7 +15,7 @@ class SSHClient(ClosingContextManager): def save_host_keys(self, filename: str) -> None: ... def get_host_keys(self) -> HostKeys: ... def set_log_channel(self, name: str) -> None: ... - def set_missing_host_key_policy(self, policy: Type[MissingHostKeyPolicy] | MissingHostKeyPolicy) -> None: ... + def set_missing_host_key_policy(self, policy: type[MissingHostKeyPolicy] | MissingHostKeyPolicy) -> None: ... def connect( self, hostname: str, diff --git a/stubs/paramiko/paramiko/ecdsakey.pyi b/stubs/paramiko/paramiko/ecdsakey.pyi index 698362879..b99315194 100644 --- a/stubs/paramiko/paramiko/ecdsakey.pyi +++ b/stubs/paramiko/paramiko/ecdsakey.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Sequence, Type +from typing import IO, Any, Callable, Sequence from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey from cryptography.hazmat.primitives.hashes import HashAlgorithm @@ -9,15 +9,15 @@ class _ECDSACurve: nist_name: str key_length: int key_format_identifier: str - hash_object: Type[HashAlgorithm] - curve_class: Type[EllipticCurve] - def __init__(self, curve_class: Type[EllipticCurve], nist_name: str) -> None: ... + hash_object: type[HashAlgorithm] + curve_class: type[EllipticCurve] + def __init__(self, curve_class: type[EllipticCurve], nist_name: str) -> None: ... class _ECDSACurveSet: ecdsa_curves: Sequence[_ECDSACurve] def __init__(self, ecdsa_curves: Sequence[_ECDSACurve]) -> None: ... def get_key_format_identifier_list(self) -> list[str]: ... - def get_by_curve_class(self, curve_class: Type[Any]) -> _ECDSACurve | None: ... + def get_by_curve_class(self, curve_class: type[Any]) -> _ECDSACurve | None: ... def get_by_key_format_identifier(self, key_format_identifier: str) -> _ECDSACurve | None: ... def get_by_key_length(self, key_length: int) -> _ECDSACurve | None: ... diff --git a/stubs/paramiko/paramiko/pkey.pyi b/stubs/paramiko/paramiko/pkey.pyi index 4990501b7..8d3659175 100644 --- a/stubs/paramiko/paramiko/pkey.pyi +++ b/stubs/paramiko/paramiko/pkey.pyi @@ -1,4 +1,4 @@ -from typing import IO, Pattern, Type, TypeVar +from typing import IO, Pattern, TypeVar from paramiko.message import Message @@ -24,9 +24,9 @@ class PKey: def sign_ssh_data(self, data: bytes) -> Message: ... def verify_ssh_sig(self, data: bytes, msg: Message) -> bool: ... @classmethod - def from_private_key_file(cls: Type[_PK], filename: str, password: str | None = ...) -> _PK: ... + def from_private_key_file(cls: type[_PK], filename: str, password: str | None = ...) -> _PK: ... @classmethod - def from_private_key(cls: Type[_PK], file_obj: IO[str], password: str | None = ...) -> _PK: ... + def from_private_key(cls: type[_PK], file_obj: IO[str], password: str | None = ...) -> _PK: ... def write_private_key_file(self, filename: str, password: str | None = ...) -> None: ... def write_private_key(self, file_obj: IO[str], password: str | None = ...) -> None: ... def load_certificate(self, value: Message | str) -> None: ... diff --git a/stubs/paramiko/paramiko/py3compat.pyi b/stubs/paramiko/paramiko/py3compat.pyi index b41a04ff2..7ef9b1cc9 100644 --- a/stubs/paramiko/paramiko/py3compat.pyi +++ b/stubs/paramiko/paramiko/py3compat.pyi @@ -1,14 +1,14 @@ import sys -from typing import Any, Iterable, Sequence, Text, Type, TypeVar +from typing import Any, Iterable, Sequence, Text, TypeVar _T = TypeVar("_T") PY2: bool -string_types: Type[Any] | Sequence[Type[Any]] -text_type: Type[Any] | Sequence[Type[Any]] -bytes_types: Type[Any] | Sequence[Type[Any]] -integer_types: Type[Any] | Sequence[Type[Any]] +string_types: type[Any] | Sequence[type[Any]] +text_type: type[Any] | Sequence[type[Any]] +bytes_types: type[Any] | Sequence[type[Any]] +integer_types: type[Any] | Sequence[type[Any]] long = int def input(prompt: Any) -> str: ... diff --git a/stubs/paramiko/paramiko/sftp_server.pyi b/stubs/paramiko/paramiko/sftp_server.pyi index 6193ea1cb..8e8dddef1 100644 --- a/stubs/paramiko/paramiko/sftp_server.pyi +++ b/stubs/paramiko/paramiko/sftp_server.pyi @@ -1,5 +1,5 @@ from logging import Logger -from typing import Any, Type +from typing import Any from paramiko.channel import Channel from paramiko.server import ServerInterface, SubsystemHandler @@ -18,7 +18,7 @@ class SFTPServer(BaseSFTP, SubsystemHandler): server: SFTPServerInterface sock: Channel | None def __init__( - self, channel: Channel, name: str, server: ServerInterface, sftp_si: Type[SFTPServerInterface], *largs: Any, **kwargs: Any + self, channel: Channel, name: str, server: ServerInterface, sftp_si: type[SFTPServerInterface], *largs: Any, **kwargs: Any ) -> None: ... def start_subsystem(self, name: str, transport: Transport, channel: Channel) -> None: ... def finish_subsystem(self) -> None: ... diff --git a/stubs/paramiko/paramiko/ssh_gss.pyi b/stubs/paramiko/paramiko/ssh_gss.pyi index 7f750a423..9c0d8bab9 100644 --- a/stubs/paramiko/paramiko/ssh_gss.pyi +++ b/stubs/paramiko/paramiko/ssh_gss.pyi @@ -1,7 +1,7 @@ -from typing import Any, Type +from typing import Any GSS_AUTH_AVAILABLE: bool -GSS_EXCEPTIONS: tuple[Type[Exception], ...] +GSS_EXCEPTIONS: tuple[type[Exception], ...] def GSSAuth(auth_method: str, gss_deleg_creds: bool = ...) -> _SSH_GSSAuth: ... diff --git a/stubs/paramiko/paramiko/transport.pyi b/stubs/paramiko/paramiko/transport.pyi index 7ebb5b97e..678a47f93 100644 --- a/stubs/paramiko/paramiko/transport.pyi +++ b/stubs/paramiko/paramiko/transport.pyi @@ -2,7 +2,7 @@ from logging import Logger from socket import socket from threading import Condition, Event, Lock, Thread from types import ModuleType -from typing import Any, Callable, Iterable, Protocol, Sequence, Type +from typing import Any, Callable, Iterable, Protocol, Sequence from paramiko.auth_handler import AuthHandler, _InteractiveCallback from paramiko.channel import Channel @@ -67,7 +67,7 @@ class Transport(Thread, ClosingContextManager): server_key_dict: dict[str, PKey] server_accepts: list[Channel] server_accept_cv: Condition - subsystem_table: dict[str, tuple[Type[SubsystemHandler], tuple[Any, ...], dict[str, Any]]] + subsystem_table: dict[str, tuple[type[SubsystemHandler], tuple[Any, ...], dict[str, Any]]] sys: ModuleType def __init__( self, @@ -138,7 +138,7 @@ class Transport(Thread, ClosingContextManager): gss_trust_dns: bool = ..., ) -> None: ... def get_exception(self) -> Exception | None: ... - def set_subsystem_handler(self, name: str, handler: Type[SubsystemHandler], *larg: Any, **kwarg: Any) -> None: ... + def set_subsystem_handler(self, name: str, handler: type[SubsystemHandler], *larg: Any, **kwarg: Any) -> None: ... def is_authenticated(self) -> bool: ... def get_username(self) -> str | None: ... def get_banner(self) -> bytes | None: ... diff --git a/stubs/paramiko/paramiko/util.pyi b/stubs/paramiko/paramiko/util.pyi index 05bd5c73f..0b72e6462 100644 --- a/stubs/paramiko/paramiko/util.pyi +++ b/stubs/paramiko/paramiko/util.pyi @@ -1,7 +1,7 @@ import sys from logging import Logger, LogRecord from types import TracebackType -from typing import IO, AnyStr, Callable, Protocol, Type, TypeVar +from typing import IO, AnyStr, Callable, Protocol, TypeVar from paramiko.config import SSHConfig, SSHConfigDict from paramiko.hostkeys import HostKeys @@ -28,7 +28,7 @@ def format_binary_line(data: bytes) -> str: ... def safe_string(s: bytes) -> bytes: ... def bit_length(n: int) -> int: ... def tb_strings() -> list[str]: ... -def generate_key_bytes(hash_alg: Type[_Hash], salt: bytes, key: bytes | str, nbytes: int) -> bytes: ... +def generate_key_bytes(hash_alg: type[_Hash], salt: bytes, key: bytes | str, nbytes: int) -> bytes: ... def load_host_keys(filename: str) -> HostKeys: ... def parse_ssh_config(file_obj: IO[str]) -> SSHConfig: ... def lookup_ssh_host_config(hostname: str, config: SSHConfig) -> SSHConfigDict: ... @@ -46,7 +46,7 @@ def constant_time_bytes_eq(a: AnyStr, b: AnyStr) -> bool: ... class ClosingContextManager: def __enter__(self: _TC) -> _TC: ... 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 clamp_value(minimum: int, val: int, maximum: int) -> int: ... diff --git a/stubs/polib/polib.pyi b/stubs/polib/polib.pyi index 695927ae5..4b6d57d9e 100644 --- a/stubs/polib/polib.pyi +++ b/stubs/polib/polib.pyi @@ -1,5 +1,5 @@ import textwrap -from typing import IO, Any, Callable, Generic, Text, Type, TypeVar, overload +from typing import IO, Any, Callable, Generic, Text, TypeVar, overload from typing_extensions import SupportsIndex _TB = TypeVar("_TB", bound="_BaseEntry") @@ -12,11 +12,11 @@ default_encoding: str # encoding: str # check_for_duplicates: bool @overload -def pofile(pofile: Text, *, klass: Type[_TP], **kwargs: Any) -> _TP: ... +def pofile(pofile: Text, *, klass: type[_TP], **kwargs: Any) -> _TP: ... @overload def pofile(pofile: Text, **kwargs: Any) -> POFile: ... @overload -def mofile(mofile: Text, *, klass: Type[_TM], **kwargs: Any) -> _TM: ... +def mofile(mofile: Text, *, klass: type[_TM], **kwargs: Any) -> _TM: ... @overload def mofile(mofile: Text, **kwargs: Any) -> MOFile: ... def detect_encoding(file: bytes | Text, binary_mode: bool = ...) -> str: ... diff --git a/stubs/pysftp/pysftp/__init__.pyi b/stubs/pysftp/pysftp/__init__.pyi index 58e051248..514900a13 100644 --- a/stubs/pysftp/pysftp/__init__.pyi +++ b/stubs/pysftp/pysftp/__init__.pyi @@ -1,6 +1,6 @@ from stat import S_IMODE as S_IMODE from types import TracebackType -from typing import IO, Any, Callable, ContextManager, Sequence, Text, Type, Union +from typing import IO, Any, Callable, ContextManager, Sequence, Text, Union from typing_extensions import Literal import paramiko @@ -122,5 +122,5 @@ class Connection: def __del__(self) -> None: ... def __enter__(self) -> "Connection": ... def __exit__( - self, etype: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + self, etype: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... diff --git a/stubs/pyvmomi/pyVmomi/vim/view.pyi b/stubs/pyvmomi/pyVmomi/vim/view.pyi index c00ad51db..114883ba3 100644 --- a/stubs/pyvmomi/pyVmomi/vim/view.pyi +++ b/stubs/pyvmomi/pyVmomi/vim/view.pyi @@ -1,4 +1,4 @@ -from typing import Any, Type +from typing import Any from pyVmomi.vim import ManagedEntity @@ -12,4 +12,4 @@ class ViewManager: # but in practice it seems to be `list[Type[ManagedEntity]]` # Source: https://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.view.ViewManager.html @staticmethod - def CreateContainerView(container: ManagedEntity, type: list[Type[ManagedEntity]], recursive: bool) -> ContainerView: ... + def CreateContainerView(container: ManagedEntity, type: list[type[ManagedEntity]], recursive: bool) -> ContainerView: ... diff --git a/stubs/pyvmomi/pyVmomi/vmodl/query.pyi b/stubs/pyvmomi/pyVmomi/vmodl/query.pyi index 89f2769c1..93e57ff5c 100644 --- a/stubs/pyvmomi/pyVmomi/vmodl/query.pyi +++ b/stubs/pyvmomi/pyVmomi/vmodl/query.pyi @@ -1,4 +1,4 @@ -from typing import Any, Type +from typing import Any from pyVmomi.vim import ManagedEntity from pyVmomi.vim.view import ContainerView @@ -6,17 +6,17 @@ from pyVmomi.vmodl import DynamicProperty class PropertyCollector: class PropertySpec: - def __init__(self, *, all: bool = ..., type: Type[ManagedEntity] = ..., pathSet: list[str] = ...) -> None: ... + def __init__(self, *, all: bool = ..., type: type[ManagedEntity] = ..., pathSet: list[str] = ...) -> None: ... all: bool - type: Type[ManagedEntity] + type: type[ManagedEntity] pathSet: list[str] class TraversalSpec: def __init__( - self, *, path: str = ..., skip: bool = ..., type: Type[ContainerView] = ..., **kwargs: Any # incomplete + self, *, path: str = ..., skip: bool = ..., type: type[ContainerView] = ..., **kwargs: Any # incomplete ) -> None: ... path: str skip: bool - type: Type[ContainerView] + type: type[ContainerView] def __getattr__(self, name: str) -> Any: ... # incomplete class RetrieveOptions: def __init__(self, *, maxObjects: int) -> None: ... diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index 9a8246a2b..468d282c8 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -1,21 +1,7 @@ import threading from _typeshed import Self, SupportsItems from datetime import datetime, timedelta -from typing import ( - Any, - Callable, - ClassVar, - Generic, - Iterable, - Iterator, - Mapping, - Pattern, - Sequence, - Type, - TypeVar, - Union, - overload, -) +from typing import Any, Callable, ClassVar, Generic, Iterable, Iterator, Mapping, Pattern, Sequence, TypeVar, Union, overload from typing_extensions import Literal from .commands import CoreCommands, RedisModuleCommands, SentinelCommands @@ -273,7 +259,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener timeout: float | None, sleep: float, blocking_timeout: float | None, - lock_class: Type[_LockType], + lock_class: type[_LockType], thread_local: bool = ..., ) -> _LockType: ... @overload @@ -284,7 +270,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener sleep: float = ..., blocking_timeout: float | None = ..., *, - lock_class: Type[_LockType], + lock_class: type[_LockType], thread_local: bool = ..., ) -> _LockType: ... def pubsub(self, *, shard_hint: Any = ..., ignore_subscribe_messages: bool = ...) -> PubSub: ... diff --git a/stubs/redis/redis/connection.pyi b/stubs/redis/redis/connection.pyi index c1261feb1..3e0b922d3 100644 --- a/stubs/redis/redis/connection.pyi +++ b/stubs/redis/redis/connection.pyi @@ -1,4 +1,4 @@ -from typing import Any, Mapping, Type +from typing import Any, Mapping from .retry import Retry @@ -87,7 +87,7 @@ class Connection: encoding: str = ..., encoding_errors: str = ..., decode_responses: bool = ..., - parser_class: Type[BaseParser] = ..., + parser_class: type[BaseParser] = ..., socket_read_size: int = ..., health_check_interval: int = ..., client_name: str | None = ..., diff --git a/stubs/redis/redis/lock.pyi b/stubs/redis/redis/lock.pyi index 7d774ccd6..db8ae5932 100644 --- a/stubs/redis/redis/lock.pyi +++ b/stubs/redis/redis/lock.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, ClassVar, Protocol, Type +from typing import Any, ClassVar, Protocol from redis.client import Redis @@ -27,7 +27,7 @@ class Lock: def register_scripts(self) -> None: ... def __enter__(self) -> Lock: ... def __exit__( - self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None + self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... def acquire( self, blocking: bool | None = ..., blocking_timeout: None | int | float = ..., token: str | bytes | None = ... diff --git a/stubs/redis/redis/sentinel.pyi b/stubs/redis/redis/sentinel.pyi index 1022cc77f..702a796c2 100644 --- a/stubs/redis/redis/sentinel.pyi +++ b/stubs/redis/redis/sentinel.pyi @@ -1,4 +1,4 @@ -from typing import Any, Type, TypeVar, overload +from typing import Any, TypeVar, overload from typing_extensions import Literal from redis.client import Redis @@ -47,9 +47,9 @@ class Sentinel(SentinelCommands): @overload def master_for(self, service_name: str, *, connection_pool_class=..., **kwargs) -> Redis[Any]: ... @overload - def master_for(self, service_name: str, redis_class: Type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ... + def master_for(self, service_name: str, redis_class: type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ... @overload def slave_for(self, service_name: str, connection_pool_class=..., **kwargs) -> Redis[Any]: ... @overload - def slave_for(self, service_name: str, redis_class: Type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ... + def slave_for(self, service_name: str, redis_class: type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ... def execute_command(self, *args, **kwargs) -> Literal[True]: ... diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index 466547a1a..190125b33 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -1,6 +1,6 @@ import datetime from json import JSONDecoder -from typing import Any, Callable, Iterator, Text, Type, TypeVar +from typing import Any, Callable, Iterator, Text, TypeVar from urllib3 import exceptions as urllib3_exceptions, fields, filepost, util @@ -129,7 +129,7 @@ class Response: def json( self, *, - cls: Type[JSONDecoder] | None = ..., + cls: type[JSONDecoder] | None = ..., object_hook: Callable[[dict[Any, Any]], Any] | None = ..., parse_float: Callable[[str], Any] | None = ..., parse_int: Callable[[str], Any] | None = ..., diff --git a/stubs/retry/retry/api.pyi b/stubs/retry/retry/api.pyi index ee8ce36ce..c74e32ee5 100644 --- a/stubs/retry/retry/api.pyi +++ b/stubs/retry/retry/api.pyi @@ -1,6 +1,6 @@ from _typeshed import IdentityFunction from logging import Logger -from typing import Any, Callable, Sequence, Type, TypeVar +from typing import Any, Callable, Sequence, TypeVar _R = TypeVar("_R") @@ -8,7 +8,7 @@ def retry_call( f: Callable[..., _R], fargs: Sequence[Any] | None = ..., fkwargs: dict[str, Any] | None = ..., - exceptions: Type[Exception] | tuple[Type[Exception], ...] = ..., + exceptions: type[Exception] | tuple[type[Exception], ...] = ..., tries: int = ..., delay: float = ..., max_delay: float | None = ..., @@ -17,7 +17,7 @@ def retry_call( logger: Logger | None = ..., ) -> _R: ... def retry( - exceptions: Type[Exception] | tuple[Type[Exception], ...] = ..., + exceptions: type[Exception] | tuple[type[Exception], ...] = ..., tries: int = ..., delay: float = ..., max_delay: float | None = ..., diff --git a/stubs/setuptools/setuptools/__init__.pyi b/stubs/setuptools/setuptools/__init__.pyi index 25bd93d13..4d1048d31 100644 --- a/stubs/setuptools/setuptools/__init__.pyi +++ b/stubs/setuptools/setuptools/__init__.pyi @@ -1,7 +1,7 @@ from abc import abstractmethod from collections.abc import Iterable, Mapping from distutils.core import Command as _Command -from typing import Any, Type +from typing import Any from setuptools._deprecation_warning import SetuptoolsDeprecationWarning as SetuptoolsDeprecationWarning from setuptools.depends import Require as Require @@ -36,14 +36,14 @@ def setup( scripts: list[str] = ..., ext_modules: list[Extension] = ..., classifiers: list[str] = ..., - distclass: Type[Distribution] = ..., + distclass: type[Distribution] = ..., script_name: str = ..., script_args: list[str] = ..., options: Mapping[str, Any] = ..., license: str = ..., keywords: list[str] | str = ..., platforms: list[str] | str = ..., - cmdclass: Mapping[str, Type[Command]] = ..., + cmdclass: Mapping[str, type[Command]] = ..., data_files: list[tuple[str, list[str]]] = ..., package_dir: Mapping[str, str] = ..., obsoletes: list[str] = ..., diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 4b1037bed..1c79752e0 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -8,7 +8,7 @@ from collections.abc import Callable, ItemsView, Iterable, Iterator as _Iterator from functools import wraps as wraps from importlib.util import spec_from_loader as spec_from_loader from io import BytesIO as BytesIO, StringIO as StringIO -from typing import Any, AnyStr, NoReturn, Pattern, Type, TypeVar, overload +from typing import Any, AnyStr, NoReturn, Pattern, TypeVar, overload from typing_extensions import Literal from . import moves as moves @@ -24,9 +24,9 @@ PY2: Literal[False] PY3: Literal[True] PY34: Literal[True] -string_types: tuple[Type[str]] -integer_types: tuple[Type[int]] -class_types: tuple[Type[Type[Any]]] +string_types: tuple[type[str]] +integer_types: tuple[type[int]] +class_types: tuple[type[type[Any]]] text_type = str binary_type = bytes @@ -77,8 +77,8 @@ def assertRegex( exec_ = exec -def reraise(tp: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ...) -> NoReturn: ... -def raise_from(value: BaseException | Type[BaseException], from_value: BaseException | None) -> NoReturn: ... +def reraise(tp: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ...) -> NoReturn: ... +def raise_from(value: BaseException | type[BaseException], from_value: BaseException | None) -> NoReturn: ... print_ = print diff --git a/stubs/toml/toml.pyi b/stubs/toml/toml.pyi index 3f8580b33..cc2902e04 100644 --- a/stubs/toml/toml.pyi +++ b/stubs/toml/toml.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import StrPath, SupportsWrite -from typing import IO, Any, Mapping, MutableMapping, Text, Type, Union +from typing import IO, Any, Mapping, MutableMapping, Text, Union if sys.version_info >= (3, 6): _PathLike = StrPath @@ -13,7 +13,7 @@ else: class TomlDecodeError(Exception): ... -def load(f: _PathLike | list[Text] | IO[str], _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... -def loads(s: Text, _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... +def load(f: _PathLike | list[Text] | IO[str], _dict: type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... +def loads(s: Text, _dict: type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... def dump(o: Mapping[str, Any], f: SupportsWrite[str]) -> str: ... def dumps(o: Mapping[str, Any]) -> str: ... diff --git a/tests/check_new_syntax.py b/tests/check_new_syntax.py index e40cfa04b..aa9c8f73f 100755 --- a/tests/check_new_syntax.py +++ b/tests/check_new_syntax.py @@ -11,10 +11,10 @@ STUBS_SUPPORTING_PYTHON_2 = frozenset( CONTEXT_MANAGER_ALIASES = {"ContextManager": "AbstractContextManager", "AsyncContextManager": "AbstractAsyncContextManager"} CONTEXTLIB_ALIAS_ALLOWLIST = frozenset({Path("stdlib/contextlib.pyi")}) -FORBIDDEN_BUILTIN_TYPING_IMPORTS = frozenset({"List", "FrozenSet", "Set", "Dict", "Tuple"}) +FORBIDDEN_BUILTIN_TYPING_IMPORTS = frozenset({"List", "FrozenSet", "Set", "Dict", "Tuple", "Type"}) IMPORTED_FROM_TYPING_NOT_TYPING_EXTENSIONS = frozenset( - {"ClassVar", "Type", "NewType", "overload", "Text", "Protocol", "runtime_checkable", "NoReturn"} + {"ClassVar", "NewType", "overload", "Text", "Protocol", "runtime_checkable", "NoReturn"} ) IMPORTED_FROM_COLLECTIONS_ABC_NOT_TYPING_EXTENSIONS = frozenset( @@ -73,7 +73,12 @@ def check_new_syntax(tree: ast.AST, path: Path) -> list[str]: elif node.module == "typing_extensions": for imported_object in node.names: imported_object_name = imported_object.name - if imported_object_name in IMPORTED_FROM_TYPING_NOT_TYPING_EXTENSIONS: + if imported_object_name in FORBIDDEN_BUILTIN_TYPING_IMPORTS: + errors.append( + f"{path}:{node.lineno}: " + f"Use `builtins.{imported_object_name.lower()}` instead of `typing_extensions.{imported_object_name}`" + ) + elif imported_object_name in IMPORTED_FROM_TYPING_NOT_TYPING_EXTENSIONS: errors.append( f"{path}:{node.lineno}: " f"Use `typing.{imported_object_name}` instead of `typing_extensions.{imported_object_name}`"