Skip to content

Commit 0be469f

Browse files
committed
fix UnionType.__or__ and add UnionType.__getitem__
1 parent bf484ab commit 0be469f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

stdlib/types.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ from collections.abc import (
1616
ValuesView,
1717
)
1818
from importlib.machinery import ModuleSpec
19-
from typing import Any, ClassVar, Literal, TypeVar, final, overload
19+
from typing import Any, ClassVar, Literal, TypeVar, _SpecialForm, final, overload
2020
from typing_extensions import ParamSpec, Self, TypeAliasType, TypeVarTuple, deprecated, disjoint_base
2121

2222
if sys.version_info >= (3, 14):
@@ -717,10 +717,12 @@ if sys.version_info >= (3, 10):
717717
def __args__(self) -> tuple[Any, ...]: ...
718718
@property
719719
def __parameters__(self) -> tuple[Any, ...]: ...
720-
def __or__(self, value: Any, /) -> UnionType: ...
721-
def __ror__(self, value: Any, /) -> UnionType: ...
720+
# the `Any` is because of underspecified binop semantics, when the rhs is a `_SpecialForm` it might result in a `_SpecialForm` (Union)
721+
def __or__(self, value: Any, /) -> UnionType | type | Any: ...
722+
def __ror__(self, value: Any, /) -> UnionType | type | Any: ...
722723
def __eq__(self, value: object, /) -> bool: ...
723724
def __hash__(self) -> int: ...
725+
def __getitem__(self, parameters: Any) -> object: ...
724726

725727
if sys.version_info >= (3, 13):
726728
@final

0 commit comments

Comments
 (0)