| 1 |
# Builtins stub used in tuple-related test cases. |
| 2 |
|
| 3 |
import _typeshed |
| 4 |
import types |
| 5 |
from typing import Iterable, Iterator, TypeVar, Generic, Sequence, Optional, overload, Tuple, Type, Self |
| 6 |
|
| 7 |
_T = TypeVar("_T") |
| 8 |
_Tco = TypeVar('_Tco', covariant=True) |
| 9 |
|
| 10 |
class object: |
| 11 |
def __init__(self) -> None: pass |
| 12 |
def __new__(cls) -> Self: ... |
| 13 |
|
| 14 |
class type: |
| 15 |
def __init__(self, *a: object) -> None: pass |
| 16 |
def __call__(self, *a: object) -> object: pass |
| 17 |
class tuple(Sequence[_Tco], Generic[_Tco]): |
| 18 |
def __hash__(self) -> int: ... |
| 19 |
def __new__(cls: Type[_T], iterable: Iterable[_Tco] = ...) -> _T: ... |
| 20 |
def __iter__(self) -> Iterator[_Tco]: pass |
| 21 |
def __contains__(self, item: object) -> bool: pass |
| 22 |
@overload |
| 23 |
def __getitem__(self, x: int) -> _Tco: pass |
| 24 |
# Real stubs use SupportsIndex, but we use int to speed up tests, as this is a common fixture. |
| 25 |
@overload |
| 26 |
def __getitem__(self, x: slice[int | None]) -> Tuple[_Tco, ...]: ... |
| 27 |
def __mul__(self, n: int) -> Tuple[_Tco, ...]: pass |
| 28 |
def __rmul__(self, n: int) -> Tuple[_Tco, ...]: pass |
| 29 |
def __add__(self, x: Tuple[_Tco, ...]) -> Tuple[_Tco, ...]: pass |
| 30 |
def count(self, obj: object) -> int: pass |
| 31 |
class function: |
| 32 |
__name__: str |
| 33 |
class ellipsis: pass |
| 34 |
class classmethod: pass |
| 35 |
|
| 36 |
# We need int and slice for indexing tuples. |
| 37 |
class int: |
| 38 |
def __neg__(self) -> 'int': pass |
| 39 |
def __pos__(self) -> 'int': pass |
| 40 |
class float: pass |
| 41 |
class slice(Generic[_Tco]): pass |
| 42 |
class bool(int): pass |
| 43 |
class str: pass # For convenience |
| 44 |
class bytes: pass |
| 45 |
class bytearray: pass |
| 46 |
|
| 47 |
class list(Sequence[_T], Generic[_T]): |
| 48 |
@overload |
| 49 |
def __getitem__(self, i: int) -> _T: ... |
| 50 |
@overload |
| 51 |
def __getitem__(self, s: slice[int | None]) -> list[_T]: ... |
| 52 |
def __contains__(self, item: object) -> bool: ... |
| 53 |
def __iter__(self) -> Iterator[_T]: ... |
| 54 |
|
| 55 |
def isinstance(x: object, t: type) -> bool: pass |
| 56 |
|
| 57 |
class BaseException: pass |
| 58 |
|
| 59 |
class dict: pass |