Skip to content

Commit 5ddc193

Browse files
committed
fix UnionType.__or__ and add UnionType.__getitem__
1 parent 7c8dce0 commit 5ddc193

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

stdlib/types.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,10 +717,13 @@ 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`
721+
# it might result in a `_SpecialForm` (Union)
722+
def __or__(self, value: Any, /) -> UnionType | type | Any: ...
723+
def __ror__(self, value: Any, /) -> UnionType | type | Any: ...
722724
def __eq__(self, value: object, /) -> bool: ...
723725
def __hash__(self) -> int: ...
726+
def __getitem__(self, parameters: Any) -> object: ...
724727

725728
if sys.version_info >= (3, 13):
726729
@final

0 commit comments

Comments
 (0)