diff --git a/stdlib/_asyncio.pyi b/stdlib/_asyncio.pyi index 76fd3048f654..8192427ffc9c 100644 --- a/stdlib/_asyncio.pyi +++ b/stdlib/_asyncio.pyi @@ -4,7 +4,7 @@ from collections.abc import Awaitable, Callable, Coroutine, Generator from contextvars import Context from types import FrameType, GenericAlias from typing import Any, Literal, TextIO, TypeAlias, TypeVar -from typing_extensions import Self, disjoint_base +from typing_extensions import Self, TypeForm, disjoint_base _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) @@ -39,7 +39,7 @@ class Future(Awaitable[_T]): def __await__(self) -> Generator[Any, None, _T]: ... @property def _loop(self) -> AbstractEventLoop: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... if sys.version_info >= (3, 12): _TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co] @@ -92,7 +92,7 @@ class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportIn def cancelling(self) -> int: ... def uncancel(self) -> int: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def get_event_loop() -> AbstractEventLoop: ... def get_running_loop() -> AbstractEventLoop: ... diff --git a/stdlib/_contextvars.pyi b/stdlib/_contextvars.pyi index 4c945121b1fe..f074fda29407 100644 --- a/stdlib/_contextvars.pyi +++ b/stdlib/_contextvars.pyi @@ -2,7 +2,7 @@ import sys from collections.abc import Callable, Iterator, Mapping from types import GenericAlias, TracebackType from typing import Any, ClassVar, Generic, ParamSpec, TypeVar, final, overload -from typing_extensions import Self +from typing_extensions import Self, TypeForm _T = TypeVar("_T") _D = TypeVar("_D") @@ -25,7 +25,7 @@ class ContextVar(Generic[_T]): def get(self, default: _D, /) -> _D | _T: ... def set(self, value: _T, /) -> Token[_T]: ... def reset(self, token: Token[_T], /) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @final class Token(Generic[_T]): @@ -35,7 +35,7 @@ class Token(Generic[_T]): def old_value(self) -> Any: ... # returns either _T or MISSING, but that's hard to express MISSING: ClassVar[object] __hash__: ClassVar[None] # type: ignore[assignment] - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... if sys.version_info >= (3, 14): def __enter__(self) -> Self: ... def __exit__( diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index ce0ad45f775c..c12383659ffb 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -7,7 +7,7 @@ from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p from types import GenericAlias from typing import Any, ClassVar, Final, Generic, Literal, SupportsIndex, TypeAlias, TypeVar, final, overload, type_check_only -from typing_extensions import Self +from typing_extensions import Self, TypeForm _T = TypeVar("_T") _CT = TypeVar("_CT", bound=_CData) @@ -344,7 +344,7 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType): # Can't inherit from Sized because the metaclass conflict between # Sized and _CData prevents using _CDataMeta. def __len__(self) -> int: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def addressof(obj: _CData | _CDataType, /) -> int: ... def alignment(obj_or_type: _CData | _CDataType | type[_CData | _CDataType], /) -> int: ... diff --git a/stdlib/_queue.pyi b/stdlib/_queue.pyi index edd484a9a71a..0037ef865be9 100644 --- a/stdlib/_queue.pyi +++ b/stdlib/_queue.pyi @@ -1,6 +1,6 @@ from types import GenericAlias from typing import Any, Generic, TypeVar -from typing_extensions import disjoint_base +from typing_extensions import TypeForm, disjoint_base _T = TypeVar("_T") @@ -15,4 +15,4 @@ class SimpleQueue(Generic[_T]): def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ... def put_nowait(self, item: _T) -> None: ... def qsize(self) -> int: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... diff --git a/stdlib/_weakrefset.pyi b/stdlib/_weakrefset.pyi index dad1ed7a4fb5..cd523e0acc80 100644 --- a/stdlib/_weakrefset.pyi +++ b/stdlib/_weakrefset.pyi @@ -1,7 +1,7 @@ from collections.abc import Iterable, Iterator, MutableSet from types import GenericAlias from typing import Any, ClassVar, TypeVar, overload -from typing_extensions import Self +from typing_extensions import Self, TypeForm __all__ = ["WeakSet"] @@ -45,4 +45,4 @@ class WeakSet(MutableSet[_T]): def union(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... def __or__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... def isdisjoint(self, other: Iterable[_T]) -> bool: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... diff --git a/stdlib/array.pyi b/stdlib/array.pyi index 4ff1e171ecfc..44c1bc48642b 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -3,7 +3,7 @@ from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite from collections.abc import Iterable, MutableSequence from types import GenericAlias from typing import Any, ClassVar, Literal, SupportsIndex, TypeAlias, TypeVar, overload -from typing_extensions import Self, deprecated, disjoint_base +from typing_extensions import Self, TypeForm, deprecated, disjoint_base _IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] if sys.version_info >= (3, 15): @@ -103,6 +103,6 @@ class array(MutableSequence[_T]): def __buffer__(self, flags: int, /) -> memoryview: ... def __release_buffer__(self, buffer: memoryview, /) -> None: ... if sys.version_info >= (3, 12): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... ArrayType = array diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 49d91004cd5a..dde3c7797dd8 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -65,7 +65,16 @@ from typing import ( # noqa: Y022,UP035 ) # we can't import `Literal` from typing or mypy crashes: see #11247 -from typing_extensions import Literal, LiteralString, Self, TypeIs, TypeVarTuple, deprecated, disjoint_base # noqa: Y023, UP035 +from typing_extensions import ( # noqa: Y023, UP035 + Literal, + LiteralString, + Self, + TypeForm, + TypeIs, + TypeVarTuple, + deprecated, + disjoint_base, +) if sys.version_info >= (3, 14): from _typeshed import AnnotateFunc @@ -150,7 +159,7 @@ class staticmethod(Generic[_P, _R_co]): def __wrapped__(self) -> Callable[_P, _R_co]: ... def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R_co: ... if sys.version_info >= (3, 14): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... __annotate__: AnnotateFunc | None @disjoint_base @@ -169,7 +178,7 @@ class classmethod(Generic[_T, _P, _R_co]): @property def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... if sys.version_info >= (3, 14): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... __annotate__: AnnotateFunc | None @disjoint_base @@ -975,7 +984,7 @@ class memoryview(Sequence[_I]): count: ClassVar[None] # type: ignore[assignment] if sys.version_info >= (3, 14): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @final class bool(int): @@ -1050,7 +1059,7 @@ class slice(Generic[_StartT_co, _StopT_co, _StepT_co]): def indices(self, len: SupportsIndex, /) -> tuple[int, int, int]: ... if sys.version_info >= (3, 15): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @disjoint_base class tuple(Sequence[_T_co]): @@ -1076,7 +1085,7 @@ class tuple(Sequence[_T_co]): def __rmul__(self, value: SupportsIndex, /) -> tuple[_T_co, ...]: ... def count(self, value: Any, /) -> int: ... def index(self, value: Any, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... # Doesn't exist at runtime, but deleting this breaks mypy and pyright. See: # https://github.com/python/typeshed/issues/7580 @@ -1181,7 +1190,7 @@ class list(MutableSequence[_T]): def __lt__(self, value: list[_T], /) -> bool: ... def __le__(self, value: list[_T], /) -> bool: ... def __eq__(self, value: object, /) -> bool: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @disjoint_base class dict(MutableMapping[_KT, _VT]): @@ -1251,7 +1260,7 @@ class dict(MutableMapping[_KT, _VT]): def __eq__(self, value: object, /) -> bool: ... def __reversed__(self) -> Iterator[_KT]: ... __hash__: ClassVar[None] # type: ignore[assignment] - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... if sys.version_info >= (3, 15): def __or__(self, value: dict[_T1, _T2] | frozendict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ... @overload @@ -1308,7 +1317,7 @@ if sys.version_info >= (3, 15): def __reversed__(self) -> Iterator[_KT]: ... def __iter__(self) -> Iterator[_KT]: ... def __hash__(self) -> int: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def __or__(self, value: dict[_T1, _T2] | frozendict[_T1, _T2], /) -> frozendict[_KT | _T1, _VT | _T2]: ... @overload def __ror__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ... @@ -1353,7 +1362,7 @@ class set(MutableSet[_T]): def __gt__(self, value: AbstractSet[object], /) -> bool: ... def __eq__(self, value: object, /) -> bool: ... __hash__: ClassVar[None] # type: ignore[assignment] - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @disjoint_base class frozenset(AbstractSet[_T_co]): @@ -1382,14 +1391,14 @@ class frozenset(AbstractSet[_T_co]): def __gt__(self, value: AbstractSet[object], /) -> bool: ... def __eq__(self, value: object, /) -> bool: ... def __hash__(self) -> int: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @disjoint_base class enumerate(Generic[_T]): def __new__(cls, iterable: Iterable[_T], start: int = 0) -> Self: ... def __iter__(self) -> Self: ... def __next__(self) -> tuple[int, _T]: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @final class range(Sequence[int]): @@ -2399,7 +2408,7 @@ if sys.version_info >= (3, 11): def derive(self, excs: Sequence[_ExceptionT], /) -> ExceptionGroup[_ExceptionT]: ... @overload def derive(self, excs: Sequence[_BaseExceptionT], /) -> BaseExceptionGroup[_BaseExceptionT]: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class ExceptionGroup(BaseExceptionGroup[_ExceptionT_co], Exception): def __new__(cls, message: str, exceptions: Sequence[_ExceptionT_co], /) -> Self: ... diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 699d4544bf4a..9c8f0fb3dac7 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -15,7 +15,7 @@ from collections.abc import ( ) from types import GenericAlias from typing import Any, ClassVar, Generic, NoReturn, SupportsIndex, TypeVar, final, overload, type_check_only -from typing_extensions import Self, disjoint_base +from typing_extensions import Self, TypeForm, disjoint_base if sys.version_info >= (3, 15): from builtins import frozendict @@ -268,7 +268,7 @@ class deque(MutableSequence[_T]): def __gt__(self, value: deque[_T], /) -> bool: ... def __ge__(self, value: deque[_T], /) -> bool: ... def __eq__(self, value: object, /) -> bool: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class Counter(dict[_T, int], Generic[_T]): @overload diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index 05680b5de461..ccf133602c08 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -5,7 +5,7 @@ from collections.abc import Callable, Iterable, Iterator from logging import Logger from types import GenericAlias, TracebackType from typing import Any, Final, Generic, NamedTuple, ParamSpec, Protocol, TypeVar, type_check_only -from typing_extensions import Self +from typing_extensions import Self, TypeForm FIRST_COMPLETED: Final = "FIRST_COMPLETED" FIRST_EXCEPTION: Final = "FIRST_EXCEPTION" @@ -49,7 +49,7 @@ class Future(Generic[_T]): def set_result(self, result: _T) -> None: ... def exception(self, timeout: float | None = None) -> BaseException | None: ... def set_exception(self, exception: BaseException | None) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class Executor: def submit(self, fn: Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Future[_T]: ... diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index 7e0bdec8bd5d..2d0a29bb83a7 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -4,7 +4,7 @@ from collections.abc import Callable, Iterable, Mapping, Set as AbstractSet from threading import Lock, Semaphore, Thread from types import GenericAlias from typing import Any, Generic, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeVarTuple, Unpack +from typing_extensions import Self, TypeForm, TypeVarTuple, Unpack from weakref import ref from ._base import BrokenExecutor, Executor, Future @@ -57,7 +57,7 @@ if sys.version_info >= (3, 14): task: _Task def __init__(self, future: Future[Any], task: _Task) -> None: ... def run(self, ctx: WorkerContext) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def _worker(executor_reference: ref[Any], ctx: WorkerContext, work_queue: queue.SimpleQueue[Any]) -> None: ... @@ -69,7 +69,7 @@ else: kwargs: Mapping[str, Any] def __init__(self, future: Future[_S], fn: Callable[..., _S], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ... def run(self) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def _worker( executor_reference: ref[Any], diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 24c1c54bba5a..1465c2759908 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -24,7 +24,7 @@ from _typeshed import SupportsWrite from collections.abc import Collection, Iterable, Mapping, Sequence from types import GenericAlias from typing import Any, Generic, Literal, TypeVar, overload -from typing_extensions import Self +from typing_extensions import Self, TypeForm __all__ = [ "QUOTE_MINIMAL", @@ -115,7 +115,7 @@ class DictReader(Generic[_T]): def __iter__(self) -> Self: ... def __next__(self) -> dict[_T | Any, str | Any]: ... if sys.version_info >= (3, 12): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class DictWriter(Generic[_T]): fieldnames: Collection[_T] @@ -143,7 +143,7 @@ class DictWriter(Generic[_T]): def writerow(self, rowdict: Mapping[_T, Any]) -> Any: ... def writerows(self, rowdicts: Iterable[Mapping[_T, Any]]) -> None: ... if sys.version_info >= (3, 12): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class Sniffer: preferred: list[str] diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 9899a4068d59..54fbfcfa6fbb 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -27,7 +27,7 @@ from _typeshed import StrPath, SupportsBool, SupportsLen from ctypes._endian import BigEndianStructure as BigEndianStructure, LittleEndianStructure as LittleEndianStructure from types import GenericAlias from typing import Any, ClassVar, Final, Generic, Literal, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self, deprecated +from typing_extensions import Self, TypeForm, deprecated if sys.platform == "win32": from _ctypes import FormatError as FormatError, get_last_error as get_last_error, set_last_error as set_last_error @@ -108,7 +108,7 @@ class LibraryLoader(Generic[_DLLT]): def __getattr__(self, name: str) -> _DLLT: ... def __getitem__(self, name: str) -> _DLLT: ... def LoadLibrary(self, name: str) -> _DLLT: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... cdll: LibraryLoader[CDLL] if sys.platform == "win32": @@ -214,7 +214,7 @@ if sys.version_info >= (3, 14): class py_object(_CanCastTo, _SimpleCData[_T]): _type_: ClassVar[Literal["O"]] if sys.version_info >= (3, 14): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class c_bool(_SimpleCData[bool]): _type_: ClassVar[Literal["?"]] diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index f24ff6a3dd50..86be5d82549f 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -6,7 +6,7 @@ from builtins import type as Type # alias to avoid name clashes with fields nam from collections.abc import Callable, Iterable, Mapping from types import GenericAlias from typing import Any, Final, Generic, Literal, Protocol, TypeVar, overload, type_check_only -from typing_extensions import Never, TypeIs +from typing_extensions import Never, TypeForm, TypeIs _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) @@ -212,7 +212,7 @@ class Field(Generic[_T]): ) -> None: ... def __set_name__(self, owner: Type[Any], name: str) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... # NOTE: Actual return type is 'Field[_T]', but we want to help type checkers # to understand the magic that happens at runtime. diff --git a/stdlib/difflib.pyi b/stdlib/difflib.pyi index 4ab59ac637b2..a9b6b11381d8 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -3,6 +3,7 @@ import sys from collections.abc import Callable, Iterable, Iterator, Sequence from types import GenericAlias from typing import Any, AnyStr, Generic, Literal, NamedTuple, TypeVar, overload +from typing_extensions import TypeForm __all__ = [ "get_close_matches", @@ -49,7 +50,7 @@ class SequenceMatcher(Generic[_T]): def ratio(self) -> float: ... def quick_ratio(self) -> float: ... def real_quick_ratio(self) -> float: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @overload def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], n: int = 3, cutoff: float = 0.6) -> list[AnyStr]: ... diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index 620cc177a415..fd33ab9d11e9 100644 --- a/stdlib/filecmp.pyi +++ b/stdlib/filecmp.pyi @@ -3,6 +3,7 @@ from _typeshed import GenericPath, StrOrBytesPath from collections.abc import Callable, Iterable, Sequence from types import GenericAlias from typing import Any, AnyStr, Final, Generic, Literal +from typing_extensions import TypeForm __all__ = ["clear_cache", "cmp", "dircmp", "cmpfiles", "DEFAULT_IGNORES"] @@ -60,6 +61,6 @@ class dircmp(Generic[AnyStr]): def phase3(self) -> None: ... def phase4(self) -> None: ... def phase4_closure(self) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def clear_cache() -> None: ... diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index 7a4f7e166970..f02bc9260c9e 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -3,7 +3,7 @@ from _typeshed import AnyStr_co, StrOrBytesPath from collections.abc import Callable, Iterable from types import GenericAlias, TracebackType from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import Self, deprecated +from typing_extensions import Self, TypeForm, deprecated __all__ = [ "input", @@ -130,7 +130,7 @@ class FileInput(Generic[AnyStr]): def fileno(self) -> int: ... def isfirstline(self) -> bool: ... def isstdin(self) -> bool: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def hook_compressed( filename: StrOrBytesPath, mode: str, *, encoding: str | None = None, errors: str | None = None diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 32b14c42b770..f9f1b02b00a5 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -17,7 +17,7 @@ from typing import ( overload, type_check_only, ) -from typing_extensions import Self, disjoint_base +from typing_extensions import Self, TypeForm, disjoint_base __all__ = [ "update_wrapper", @@ -177,7 +177,7 @@ class partial(Generic[_T]): def keywords(self) -> dict[str, Any]: ... def __new__(cls, func: Callable[..., _T], /, *args: Any, **kwargs: Any) -> Self: ... def __call__(self, /, *args: Any, **kwargs: Any) -> _T: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... # With protocols, this could change into a generic protocol that defines __get__ and returns _T _Descriptor: TypeAlias = Any @@ -200,7 +200,7 @@ class partialmethod(Generic[_T]): def __get__(self, obj: Any, cls: type[Any] | None = None) -> Callable[..., _T]: ... @property def __isabstractmethod__(self) -> bool: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... if sys.version_info >= (3, 11): _RegType: TypeAlias = type[Any] | types.UnionType @@ -252,7 +252,7 @@ class cached_property(Generic[_T_co]): def __set_name__(self, owner: type[Any], name: str) -> None: ... # __set__ is not defined at runtime, but @cached_property is designed to be settable def __set__(self, instance: object, value: _T_co) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def cache(user_function: Callable[..., _T], /) -> _lru_cache_wrapper[_T]: ... def _make_key( diff --git a/stdlib/graphlib.pyi b/stdlib/graphlib.pyi index 1ca8cbe12b08..4f8d85b0e6c8 100644 --- a/stdlib/graphlib.pyi +++ b/stdlib/graphlib.pyi @@ -2,6 +2,7 @@ import sys from _typeshed import SupportsItems from collections.abc import Iterable from typing import Any, Generic, TypeVar, overload +from typing_extensions import TypeForm __all__ = ["TopologicalSorter", "CycleError"] @@ -23,6 +24,6 @@ class TopologicalSorter(Generic[_T]): def get_ready(self) -> tuple[_T, ...]: ... def static_order(self) -> Iterable[_T]: ... if sys.version_info >= (3, 11): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class CycleError(ValueError): ... diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index b0dd49723cd5..a9942acf4b16 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -2,6 +2,7 @@ from _typeshed import MaybeNone, SupportsItems, SupportsKeysAndGetItem from collections.abc import Container, Iterable from types import GenericAlias from typing import Any, Generic, TypeVar, overload +from typing_extensions import TypeForm __all__ = ["CookieError", "BaseCookie", "SimpleCookie"] @@ -37,7 +38,7 @@ class Morsel(dict[str, Any], Generic[_T]): def OutputString(self, attrs: Container[str] | None = None) -> str: ... def __eq__(self, morsel: object) -> bool: ... def __setitem__(self, K: str, V: Any) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class BaseCookie(dict[str, Morsel[_T]], Generic[_T]): def __init__(self, input: str | SupportsItems[str, str | Morsel[Any]] | None = None) -> None: ... diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 76844c0cc285..4572d94fa99d 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -3,7 +3,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable, Iterator from types import GenericAlias from typing import Any, Generic, Literal, SupportsComplex, SupportsFloat, SupportsIndex, SupportsInt, TypeAlias, TypeVar, overload -from typing_extensions import Self, disjoint_base +from typing_extensions import Self, TypeForm, disjoint_base _T = TypeVar("_T") _S = TypeVar("_S") @@ -71,7 +71,7 @@ class chain(Generic[_T]): @classmethod # We use type[Any] and not type[_S] to not lose the type inference from __iterable def from_iterable(cls: type[Any], iterable: Iterable[Iterable[_S]], /) -> chain[_S]: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @disjoint_base class compress(Generic[_T]): diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 6182981597e4..4703af6862b9 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -8,7 +8,7 @@ from string import Template from time import struct_time from types import FrameType, GenericAlias, TracebackType from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self, deprecated +from typing_extensions import Self, TypeForm, deprecated __all__ = [ "BASIC_FORMAT", @@ -478,7 +478,7 @@ class LoggerAdapter(Generic[_L]): @property def name(self) -> str: ... # undocumented if sys.version_info >= (3, 11): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def getLogger(name: str | None = None) -> Logger: ... def getLoggerClass() -> type[Logger]: ... @@ -617,7 +617,7 @@ class StreamHandler(Handler, Generic[_StreamT]): def __init__(self: StreamHandler[_StreamT], stream: _StreamT) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 def setStream(self, stream: _StreamT) -> _StreamT | None: ... if sys.version_info >= (3, 11): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class FileHandler(StreamHandler[TextIOWrapper]): baseFilename: str # undocumented diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index cbb051905737..ce202db2c1de 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -6,7 +6,7 @@ from abc import ABCMeta, abstractmethod from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from types import GenericAlias, TracebackType from typing import Any, Generic, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only -from typing_extensions import Self +from typing_extensions import Self, TypeForm __all__ = [ "Mailbox", @@ -125,7 +125,7 @@ class Mailbox(Generic[_MessageT_co]): def close(self) -> None: ... # Undocumented, called by subclasses to parse added messages. def _dump_message(self, message: _MessageData, target: SupportsWrite[bytes], mangle_from_: bool = False) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class Maildir(Mailbox[MaildirMessage]): colon: str @@ -283,7 +283,7 @@ class _ProxyFile: def flush(self) -> None: ... @property def closed(self) -> bool: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class _PartialFile(_ProxyFile): def __init__(self, f: _GetFileReturn, start: int | None = None, stop: int | None = None) -> None: ... diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 5e69683d2dda..d732f8865226 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -15,7 +15,7 @@ from collections.abc import ( ) from types import GenericAlias, TracebackType from typing import Any, AnyStr, ClassVar, Generic, SupportsIndex, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing_extensions import Self, TypeForm from . import pool from .connection import Connection, _Address @@ -70,7 +70,7 @@ class ValueProxy(BaseProxy, Generic[_T]): def get(self) -> _T: ... def set(self, value: _T) -> None: ... value: _T - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... if sys.version_info >= (3, 13): class _BaseDictProxy(BaseProxy, MutableMapping[_KT, _VT]): @@ -185,7 +185,7 @@ if sys.version_info >= (3, 14): def __ror__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... # type: ignore[misc] def __rsub__(self, value: AbstractSet[_T], /) -> set[_T]: ... def __rxor__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... # type: ignore[misc] - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class SetProxy(_BaseSetProxy[_T]): ... diff --git a/stdlib/multiprocessing/pool.pyi b/stdlib/multiprocessing/pool.pyi index b79f9e77359a..eacccfe20f64 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -2,7 +2,7 @@ from collections.abc import Callable, Iterable, Mapping from multiprocessing.context import DefaultContext, Process from types import GenericAlias, TracebackType from typing import Any, Final, Generic, TypeVar -from typing_extensions import Self +from typing_extensions import Self, TypeForm __all__ = ["Pool", "ThreadPool"] @@ -17,7 +17,7 @@ class ApplyResult(Generic[_T]): def wait(self, timeout: float | None = None) -> None: ... def ready(self) -> bool: ... def successful(self) -> bool: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... # alias created during issue #17805 AsyncResult = ApplyResult diff --git a/stdlib/multiprocessing/queues.pyi b/stdlib/multiprocessing/queues.pyi index 8f0feb834619..59804d405c9b 100644 --- a/stdlib/multiprocessing/queues.pyi +++ b/stdlib/multiprocessing/queues.pyi @@ -1,6 +1,7 @@ import sys from types import GenericAlias from typing import Any, Generic, NewType, TypeVar +from typing_extensions import TypeForm __all__ = ["Queue", "SimpleQueue", "JoinableQueue"] @@ -27,7 +28,7 @@ class Queue(Generic[_T]): def join_thread(self) -> None: ... def cancel_join_thread(self) -> None: ... if sys.version_info >= (3, 12): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class JoinableQueue(Queue[_T]): def __getstate__(self) -> _JoinableQueueState: ... # type: ignore[override] @@ -43,4 +44,4 @@ class SimpleQueue(Generic[_T]): def __setstate__(self, state: _SimpleQueueState) -> None: ... def get(self) -> _T: ... def put(self, obj: _T) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... diff --git a/stdlib/multiprocessing/shared_memory.pyi b/stdlib/multiprocessing/shared_memory.pyi index f75a372a69a2..20642d5ccf61 100644 --- a/stdlib/multiprocessing/shared_memory.pyi +++ b/stdlib/multiprocessing/shared_memory.pyi @@ -2,7 +2,7 @@ import sys from collections.abc import Iterable from types import GenericAlias from typing import Any, Generic, TypeVar, overload -from typing_extensions import Self +from typing_extensions import Self, TypeForm __all__ = ["SharedMemory", "ShareableList"] @@ -38,4 +38,4 @@ class ShareableList(Generic[_SLT]): def format(self) -> str: ... def count(self, value: _SLT) -> int: ... def index(self, value: _SLT) -> int: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 506623905a9d..97e1fe95458a 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -42,7 +42,7 @@ from typing import ( runtime_checkable, type_check_only, ) -from typing_extensions import LiteralString, Self, Unpack, deprecated +from typing_extensions import LiteralString, Self, TypeForm, Unpack, deprecated from . import path as _path @@ -905,7 +905,7 @@ class DirEntry(Generic[AnyStr]): def is_symlink(self) -> bool: ... def stat(self, *, follow_symlinks: bool = True) -> stat_result: ... def __fspath__(self) -> AnyStr: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... if sys.version_info >= (3, 12): def is_junction(self) -> bool: ... diff --git a/stdlib/queue.pyi b/stdlib/queue.pyi index 65e2ac1559ad..61b9bf1a3dc8 100644 --- a/stdlib/queue.pyi +++ b/stdlib/queue.pyi @@ -4,6 +4,7 @@ from _typeshed import SupportsRichComparisonT from threading import Condition, Lock from types import GenericAlias from typing import Any, Generic, TypeVar +from typing_extensions import TypeForm __all__ = ["Empty", "Full", "Queue", "PriorityQueue", "LifoQueue", "SimpleQueue"] if sys.version_info >= (3, 13): @@ -46,7 +47,7 @@ class Queue(Generic[_T]): def qsize(self) -> int: ... def _qsize(self) -> int: ... def task_done(self) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class PriorityQueue(Queue[SupportsRichComparisonT]): queue: list[SupportsRichComparisonT] diff --git a/stdlib/re.pyi b/stdlib/re.pyi index 2c81aa93eca5..8820d599926c 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -4,7 +4,7 @@ from _typeshed import MaybeNone, ReadableBuffer from collections.abc import Callable, Iterator, Mapping from types import GenericAlias from typing import Any, AnyStr, Final, Generic, Literal, TypeAlias, TypeVar, final, overload -from typing_extensions import deprecated +from typing_extensions import TypeForm, deprecated __all__ = [ "match", @@ -116,7 +116,7 @@ class Match(Generic[AnyStr]): def __getitem__(self, key: int | str, /) -> AnyStr | MaybeNone: ... def __copy__(self) -> Match[AnyStr]: ... def __deepcopy__(self, memo: Any, /) -> Match[AnyStr]: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @final class Pattern(Generic[AnyStr]): @@ -198,7 +198,7 @@ class Pattern(Generic[AnyStr]): def __deepcopy__(self, memo: Any, /) -> Pattern[AnyStr]: ... def __eq__(self, value: object, /) -> bool: ... def __hash__(self) -> int: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... # ----- re variables and constants ----- diff --git a/stdlib/string/templatelib.pyi b/stdlib/string/templatelib.pyi index ee901cdc43b8..6c94c7830726 100644 --- a/stdlib/string/templatelib.pyi +++ b/stdlib/string/templatelib.pyi @@ -1,6 +1,7 @@ from collections.abc import Iterator from types import GenericAlias from typing import Any, Generic, Literal, TypeVar, final, overload +from typing_extensions import TypeForm _T = TypeVar("_T") @@ -12,7 +13,7 @@ class Template: # TODO: consider making `Template` generic on `TypeVarTuple` def __new__(cls, *args: str | Interpolation[Any]) -> Template: ... def __iter__(self) -> Iterator[str | Interpolation[Any]]: ... def __add__(self, other: Template, /) -> Template: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @property def values(self) -> tuple[Any, ...]: ... # Tuple of interpolation values, which can have any type @@ -28,7 +29,7 @@ class Interpolation(Generic[_T]): def __new__( cls, value: _T, expression: str = "", conversion: Literal["a", "r", "s"] | None = None, format_spec: str = "" ) -> Interpolation[_T]: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @overload def convert(obj: _T, /, conversion: None) -> _T: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 09c55e37188e..1fb12c4a361f 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -3,7 +3,7 @@ from _typeshed import MaybeNone, ReadableBuffer, StrOrBytesPath from collections.abc import Callable, Collection, Iterable, Mapping, Sequence from types import GenericAlias, TracebackType from typing import IO, Any, AnyStr, Final, Generic, Literal, TypeAlias, TypeVar, overload -from typing_extensions import Self +from typing_extensions import Self, TypeForm __all__ = [ "Popen", @@ -84,7 +84,7 @@ class CompletedProcess(Generic[_T]): stderr: _T def __init__(self, args: _CMD, returncode: int, stdout: _T | None = None, stderr: _T | None = None) -> None: ... def check_returncode(self) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... if sys.version_info >= (3, 11): # 3.11 adds "process_group" argument @@ -1426,7 +1426,7 @@ class Popen(Generic[AnyStr]): self, exc_type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def __del__(self) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... # The result really is always a str. if sys.version_info >= (3, 11): diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 1e8e8679add5..06053eeda10a 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -15,7 +15,7 @@ from _typeshed import ( from collections.abc import Iterable, Iterator from types import GenericAlias, TracebackType from typing import IO, Any, AnyStr, Final, Generic, Literal, overload -from typing_extensions import Self, deprecated +from typing_extensions import Self, TypeForm, deprecated __all__ = [ "NamedTemporaryFile", @@ -396,7 +396,7 @@ class SpooledTemporaryFile(IO[AnyStr], _SpooledTemporaryFileBase): def seekable(self) -> bool: ... def writable(self) -> bool: ... def __next__(self) -> AnyStr: ... # type: ignore[override] - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class TemporaryDirectory(Generic[AnyStr]): name: AnyStr @@ -442,7 +442,7 @@ class TemporaryDirectory(Generic[AnyStr]): def cleanup(self) -> None: ... def __enter__(self) -> AnyStr: ... def __exit__(self, exc: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... # The overloads overlap, but they should still work fine. @overload diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 3924150c8dc1..d14e4be5b4fe 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -20,7 +20,7 @@ from typing import ( overload, type_check_only, ) -from typing_extensions import TypeVarTuple, Unpack, deprecated, disjoint_base +from typing_extensions import TypeForm, TypeVarTuple, Unpack, deprecated, disjoint_base if sys.version_info >= (3, 11): from enum import StrEnum @@ -317,7 +317,7 @@ class Event(Generic[_W_co]): detail: str user_data: str if sys.version_info >= (3, 14): - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def NoDefaultRoot() -> None: ... diff --git a/stdlib/types.pyi b/stdlib/types.pyi index d2a8335b0908..f2cc35504cec 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -18,7 +18,7 @@ from collections.abc import ( ) from importlib.machinery import ModuleSpec from typing import Any, ClassVar, Literal, ParamSpec, TypeVar, final, overload -from typing_extensions import Self, TypeAliasType, TypeVarTuple, deprecated, disjoint_base +from typing_extensions import Self, TypeAliasType, TypeForm, TypeVarTuple, deprecated, disjoint_base if sys.version_info >= (3, 14): from _typeshed import AnnotateFunc @@ -284,7 +284,7 @@ class MappingProxyType(Mapping[_KT_co, _VT_co]): # type: ignore[type-var] # py def get(self, key: _KT_co, default: _VT_co, /) -> _VT_co: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter @overload def get(self, key: _KT_co, default: _T2, /) -> _VT_co | _T2: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... def __reversed__(self) -> Iterator[_KT_co]: ... def __or__(self, value: Mapping[_T1, _T2], /) -> dict[_KT_co | _T1, _VT_co | _T2]: ... def __ror__(self, value: Mapping[_T1, _T2], /) -> dict[_KT_co | _T1, _VT_co | _T2]: ... @@ -381,7 +381,7 @@ class GeneratorType(Generator[_YieldT_co, _SendT_contra, _ReturnT_co]): @overload def throw(self, typ: BaseException, val: None = None, tb: TracebackType | None = ..., /) -> _YieldT_co: ... if sys.version_info >= (3, 13): - def __class_getitem__(cls, item: Any, /) -> Any: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> Any: ... @final class AsyncGeneratorType(AsyncGenerator[_YieldT_co, _SendT_contra]): @@ -412,7 +412,7 @@ class AsyncGeneratorType(AsyncGenerator[_YieldT_co, _SendT_contra]): @overload async def athrow(self, typ: BaseException, val: None = None, tb: TracebackType | None = ..., /) -> _YieldT_co: ... def aclose(self) -> Coroutine[Any, Any, None]: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... # Non-default variations to accommodate coroutines _SendT_nd_contra = TypeVar("_SendT_nd_contra", contravariant=True) @@ -449,7 +449,7 @@ class CoroutineType(Coroutine[_YieldT_co, _SendT_nd_contra, _ReturnT_nd_co]): @overload def throw(self, typ: BaseException, val: None = None, tb: TracebackType | None = ..., /) -> _YieldT_co: ... if sys.version_info >= (3, 13): - def __class_getitem__(cls, item: Any, /) -> Any: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> Any: ... @final class MethodType: diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index f40e84366a8d..c3b984d67197 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -21,7 +21,7 @@ from typing import ( overload, type_check_only, ) -from typing_extensions import Never, Self +from typing_extensions import Never, Self, TypeForm from unittest._log import _AssertLogsContext, _LoggingWatcher from warnings import WarningMessage @@ -328,7 +328,7 @@ class _AssertRaisesContext(_AssertRaisesBaseContext, Generic[_E]): def __exit__( self, exc_type: type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None ) -> bool: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class _AssertWarnsContext(_AssertRaisesBaseContext): warning: WarningMessage diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index d9ba692bd6e9..4b493e4484cb 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -2,7 +2,7 @@ import sys from collections.abc import Iterable, Mapping, Sequence from types import GenericAlias from typing import Any, AnyStr, Final, Generic, Literal, NamedTuple, Protocol, TypeAlias, overload, type_check_only -from typing_extensions import TypeVar +from typing_extensions import TypeForm, TypeVar __all__ = [ "urlparse", @@ -61,7 +61,7 @@ class _NetlocResultMixinBase(Generic[AnyStr]): def hostname(self) -> AnyStr | None: ... @property def port(self) -> int | None: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): __slots__ = () diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index 53310c91b83a..2872b27a9c1c 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -4,7 +4,7 @@ from _weakrefset import WeakSet as WeakSet from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping from types import GenericAlias from typing import Any, ClassVar, Generic, ParamSpec, TypeVar, final, overload -from typing_extensions import Self, disjoint_base +from typing_extensions import Self, TypeForm, disjoint_base __all__ = [ "ref", @@ -59,7 +59,7 @@ class ReferenceType(Generic[_T]): # "weakref" def __call__(self) -> _T | None: ... def __eq__(self, value: object, /) -> bool: ... def __hash__(self) -> int: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... ref = ReferenceType diff --git a/stubs/gevent/gevent/queue.pyi b/stubs/gevent/gevent/queue.pyi index e0a504edba15..655a8df6d99c 100644 --- a/stubs/gevent/gevent/queue.pyi +++ b/stubs/gevent/gevent/queue.pyi @@ -6,7 +6,7 @@ from collections.abc import Iterable # technically it is using _PySimpleQueue, which has the same interface as SimpleQueue from queue import Empty as Empty, Full as Full from typing import Any, Generic, Literal, TypeVar, final, overload -from typing_extensions import Self +from typing_extensions import Self, TypeForm from gevent._waiter import Waiter from gevent.hub import Hub @@ -30,7 +30,7 @@ class SimpleQueue(Generic[_T]): is_shutdown: bool @classmethod - def __class_getitem__(cls, item: Any, /) -> types.GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> types.GenericAlias: ... @overload def __init__(self, maxsize: int | None = None) -> None: ... @overload @@ -95,7 +95,7 @@ class Channel(Generic[_T]): def hub(self) -> Hub: ... # readonly in Cython def __init__(self, maxsize: Literal[1] = 1) -> None: ... @classmethod - def __class_getitem__(cls, item: Any, /) -> types.GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> types.GenericAlias: ... @property def balance(self) -> int: ... def qsize(self) -> Literal[0]: ... diff --git a/stubs/regex/regex/_main.pyi b/stubs/regex/regex/_main.pyi index 49c66bb0248c..3fce78929b77 100644 --- a/stubs/regex/regex/_main.pyi +++ b/stubs/regex/regex/_main.pyi @@ -2,7 +2,7 @@ from _typeshed import ReadableBuffer, Unused from collections.abc import Callable, Mapping from types import GenericAlias from typing import Any, AnyStr, Generic, Literal, TypeVar, final, overload -from typing_extensions import Self +from typing_extensions import Self, TypeForm from . import _regex from ._regex_core import * @@ -637,7 +637,7 @@ class Pattern(Generic[AnyStr]): ) -> _regex.Scanner[bytes]: ... def __copy__(self) -> Self: ... def __deepcopy__(self, memo: Unused, /) -> Self: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ... @final class Match(Generic[AnyStr]): @@ -715,4 +715,4 @@ class Match(Generic[AnyStr]): def __getitem__(self, key: int | str, /) -> AnyStr | Any: ... def __copy__(self) -> Self: ... def __deepcopy__(self, memo: Unused, /) -> Self: ... - def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... + def __class_getitem__(cls, item: TypeForm[Any], /) -> GenericAlias: ...