diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 1163d71d2c95..75d34aabee90 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -16,7 +16,7 @@ from collections.abc import ( ValuesView, ) from importlib.machinery import ModuleSpec -from typing import Any, ClassVar, Literal, TypeVar, final, overload +from typing import Any, ClassVar, Literal, TypeVar, Union, final, overload from typing_extensions import ParamSpec, Self, TypeAliasType, TypeVarTuple, deprecated if sys.version_info >= (3, 14): @@ -675,17 +675,9 @@ class GenericAlias: # GenericAlias delegates attr access to `__origin__` def __getattr__(self, name: str) -> Any: ... -if sys.version_info >= (3, 10): - @final - class NoneType: - def __bool__(self) -> Literal[False]: ... - - @final - class EllipsisType: ... - - from builtins import _NotImplementedType - - NotImplementedType = _NotImplementedType +if sys.version_info >= (3, 14): + UnionType = Union +elif sys.version_info >= (3, 10): @final class UnionType: @property @@ -697,6 +689,17 @@ if sys.version_info >= (3, 10): def __eq__(self, value: object, /) -> bool: ... def __hash__(self) -> int: ... + @final + class NoneType: + def __bool__(self) -> Literal[False]: ... + + @final + class EllipsisType: ... + + from builtins import _NotImplementedType + + NotImplementedType = _NotImplementedType + if sys.version_info >= (3, 13): @final class CapsuleType: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 5aa85543ed2c..bf878e4fba58 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -235,7 +235,22 @@ class _SpecialForm(_Final): def __or__(self, other: Any) -> _SpecialForm: ... def __ror__(self, other: Any) -> _SpecialForm: ... -Union: _SpecialForm +if sys.version_info >= (3, 14): + @final + class Union: + @property + def __args__(self) -> tuple[Any, ...]: ... + @property + def __parameters__(self) -> tuple[Any, ...]: ... + def __or__(self, value: Any, /) -> UnionType: ... + def __ror__(self, value: Any, /) -> UnionType: ... + def __eq__(self, value: object, /) -> bool: ... + def __hash__(self) -> int: ... + def __class_getitem__(cls, item: Any) -> Self: ... + +else: + Union: _SpecialForm + Generic: _SpecialForm Protocol: _SpecialForm Callable: _SpecialForm