Skip to content

Commit fc1062c

Browse files
fix type.__or__ (#14813)
Co-authored-by: Alex Waygood <[email protected]>
1 parent 565cd2d commit fc1062c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

stdlib/builtins.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ class type:
226226
@classmethod
227227
def __prepare__(metacls, name: str, bases: tuple[type, ...], /, **kwds: Any) -> MutableMapping[str, object]: ...
228228
if sys.version_info >= (3, 10):
229-
def __or__(self, value: Any, /) -> types.UnionType: ...
230-
def __ror__(self, value: Any, /) -> types.UnionType: ...
229+
# `int | str` produces an instance of `UnionType`, but `int | int` produces an instance of `type`,
230+
# and `abc.ABC | abc.ABC` produces an instance of `abc.ABCMeta`.
231+
def __or__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ...
232+
def __ror__(self: _typeshed.Self, value: Any, /) -> types.UnionType | _typeshed.Self: ...
231233
if sys.version_info >= (3, 12):
232234
__type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...]
233235
__annotations__: dict[str, AnnotationForm]

0 commit comments

Comments
 (0)