| 1 |
# More complete stub for typing module. |
| 2 |
# |
| 3 |
# Use [typing fixtures/typing-medium.pyi] to use this instead of lib-stub/typing.pyi |
| 4 |
# in a particular test case. |
| 5 |
# |
| 6 |
# Many of the definitions have special handling in the type checker, so they |
| 7 |
# can just be initialized to anything. |
| 8 |
|
| 9 |
cast = 0 |
| 10 |
overload = 0 |
| 11 |
Any = object() |
| 12 |
Union = 0 |
| 13 |
Optional = 0 |
| 14 |
TypeVar = 0 |
| 15 |
Generic = 0 |
| 16 |
Protocol = 0 |
| 17 |
Tuple = 0 |
| 18 |
Callable = 0 |
| 19 |
_promote = 0 |
| 20 |
NamedTuple = 0 |
| 21 |
Type = 0 |
| 22 |
no_type_check = 0 |
| 23 |
ClassVar = 0 |
| 24 |
Final = 0 |
| 25 |
Literal = 0 |
| 26 |
TypedDict = 0 |
| 27 |
NoReturn = 0 |
| 28 |
NewType = 0 |
| 29 |
TypeAlias = 0 |
| 30 |
LiteralString = 0 |
| 31 |
Self = 0 |
| 32 |
|
| 33 |
T = TypeVar('T') |
| 34 |
T_co = TypeVar('T_co', covariant=True) |
| 35 |
R_co = TypeVar('R_co', covariant=True) |
| 36 |
S_contra = TypeVar('S_contra', contravariant=True) |
| 37 |
|
| 38 |
# Note: definitions below are different from typeshed, variances are declared |
| 39 |
# to silence the protocol variance checks. Maybe it is better to use type: ignore? |
| 40 |
|
| 41 |
class Sized(Protocol): |
| 42 |
def __len__(self) -> int: pass |
| 43 |
|
| 44 |
class Iterable(Protocol[T_co]): |
| 45 |
def __iter__(self) -> 'Iterator[T_co]': pass |
| 46 |
|
| 47 |
class Iterator(Iterable[T_co], Protocol): |
| 48 |
def __next__(self) -> T_co: pass |
| 49 |
|
| 50 |
class Generator(Iterator[T_co], Generic[T_co, S_contra, R_co]): |
| 51 |
def __iter__(self) -> 'Generator[T_co, S_contra, R_co]': pass |
| 52 |
|
| 53 |
class Sequence(Iterable[T_co]): |
| 54 |
def __getitem__(self, n: Any) -> T_co: pass |
| 55 |
|
| 56 |
class Mapping(Iterable[T], Generic[T, T_co]): |
| 57 |
def keys(self) -> Iterable[T]: pass # Approximate return type |
| 58 |
def __getitem__(self, key: T) -> T_co: pass |
| 59 |
|
| 60 |
class SupportsInt(Protocol): |
| 61 |
def __int__(self) -> int: pass |
| 62 |
|
| 63 |
class SupportsFloat(Protocol): |
| 64 |
def __float__(self) -> float: pass |
| 65 |
|
| 66 |
class ContextManager(Generic[T_co]): |
| 67 |
def __enter__(self) -> T_co: pass |
| 68 |
# Use Any because not all the precise types are in the fixtures. |
| 69 |
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> Any: pass |
| 70 |
|
| 71 |
class _SpecialForm: pass |
| 72 |
|
| 73 |
TYPE_CHECKING = 1 |