Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update typing.Union and types.UnionType definitions for 3.14 #13740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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: ...
17 changes: 16 additions & 1 deletion stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading