| 1 |
# Stub for typing module. Many of the definitions have special handling in |
| 2 |
# the type checker, so they can just be initialized to anything. |
| 3 |
# |
| 4 |
# DO NOT ADD TO THIS FILE UNLESS YOU HAVE A GOOD REASON! Additional definitions |
| 5 |
# will slow down tests. |
| 6 |
# |
| 7 |
# Use [typing fixtures/typing-{medium,full,async,...}.pyi] in a test case for |
| 8 |
# a more complete stub for typing. If you need to add things, add to one of |
| 9 |
# the stubs under fixtures/. |
| 10 |
|
| 11 |
cast = 0 |
| 12 |
assert_type = 0 |
| 13 |
overload = 0 |
| 14 |
Any = object() |
| 15 |
Union = 0 |
| 16 |
Optional = 0 |
| 17 |
TypeVar = 0 |
| 18 |
Generic = 0 |
| 19 |
Protocol = 0 |
| 20 |
Tuple = 0 |
| 21 |
Callable = 0 |
| 22 |
NamedTuple = 0 |
| 23 |
Type = 0 |
| 24 |
ClassVar = 0 |
| 25 |
Final = 0 |
| 26 |
Literal = 0 |
| 27 |
NoReturn = 0 |
| 28 |
Never = 0 |
| 29 |
NewType = 0 |
| 30 |
ParamSpec = 0 |
| 31 |
TypeVarTuple = 0 |
| 32 |
Unpack = 0 |
| 33 |
Self = 0 |
| 34 |
TYPE_CHECKING = 0 |
| 35 |
|
| 36 |
T = TypeVar('T') |
| 37 |
T_co = TypeVar('T_co', covariant=True) |
| 38 |
S_contra = TypeVar('S_contra', contravariant=True) |
| 39 |
R_co = TypeVar('R_co', covariant=True) |
| 40 |
|
| 41 |
class Iterable(Protocol[T_co]): |
| 42 |
def __iter__(self) -> Iterator[T_co]: pass |
| 43 |
|
| 44 |
class Iterator(Iterable[T_co], Protocol): |
| 45 |
def __next__(self) -> T_co: pass |
| 46 |
|
| 47 |
class Generator(Iterator[T_co], Generic[T_co, S_contra, R_co]): |
| 48 |
def __iter__(self) -> Generator[T_co, S_contra, R_co]: pass |
| 49 |
|
| 50 |
class Sequence(Iterable[T_co]): |
| 51 |
def __getitem__(self, n: Any) -> T_co: pass |
| 52 |
def __len__(self) -> int: pass |
| 53 |
|
| 54 |
# Mapping type is oversimplified intentionally. |
| 55 |
class Mapping(Iterable[T], Generic[T, T_co]): |
| 56 |
def keys(self) -> Iterable[T]: pass # Approximate return type |
| 57 |
def __getitem__(self, key: T) -> T_co: pass |
| 58 |
|
| 59 |
class Awaitable(Protocol[T_co]): |
| 60 |
def __await__(self) -> Generator[Any, Any, T_co]: pass |
| 61 |
|
| 62 |
class Coroutine(Awaitable[R_co], Generic[T_co, S_contra, R_co]): pass |
| 63 |
|
| 64 |
def final(meth: T) -> T: pass |
| 65 |
|
| 66 |
def reveal_type(__obj: T) -> T: pass |
| 67 |
|
| 68 |
class _SpecialForm: pass |