Add __(r)or__ to various typing classes (#6498)

- `__or__` was added to `TypeVar` in Python 3.10: https://bugs.python.org/issue41428 (this PR: https://github.com/python/cpython/pull/21515)
- `__or__` was added to `ForwardRef` in Python 3.11: https://bugs.python.org/issue45489
This commit is contained in:
Alex Waygood
2021-12-05 23:16:19 +00:00
committed by GitHub
parent 3f316b0ffb
commit ff4bd7c465

View File

@@ -29,11 +29,17 @@ class TypeVar:
covariant: bool = ...,
contravariant: bool = ...,
) -> None: ...
if sys.version_info >= (3, 10):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
_promote = object()
class _SpecialForm:
def __getitem__(self, typeargs: Any) -> object: ...
if sys.version_info >= (3, 10):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
_F = TypeVar("_F", bound=Callable[..., Any])
_P = _ParamSpec("_P")
@@ -80,6 +86,8 @@ if sys.version_info >= (3, 10):
def args(self) -> ParamSpecArgs: ...
@property
def kwargs(self) -> ParamSpecKwargs: ...
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
Concatenate: _SpecialForm = ...
TypeAlias: _SpecialForm = ...
TypeGuard: _SpecialForm = ...
@@ -727,6 +735,9 @@ if sys.version_info >= (3, 7):
def __eq__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
def __repr__(self) -> str: ...
if sys.version_info >= (3, 11):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
if sys.version_info >= (3, 10):
def is_typeddict(tp: Any) -> bool: ...