Skip to content

Commit 31978d9

Browse files
committed
fix type.__or__
1 parent 91055c7 commit 31978d9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import sys
2+
from types import UnionType
3+
from typing_extensions import assert_type
4+
5+
if sys.version_info >= (3, 10):
6+
# pyright has special-casing that causes this failure
7+
assert_type(int | int, UnionType | type[int]) # pyright: ignore[reportAssertTypeFailure]

stdlib/builtins.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ 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+
def __or__(self, value: Any, /) -> types.UnionType | Self: ...
230+
def __ror__(self, value: Any, /) -> types.UnionType | Self: ...
231231
if sys.version_info >= (3, 12):
232232
__type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...]
233233
__annotations__: dict[str, AnnotationForm]

0 commit comments

Comments
 (0)