-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Expand file tree
/
Copy pathtyping-typeddict.pyi
More file actions
85 lines (72 loc) · 2.63 KB
/
Copy pathtyping-typeddict.pyi
File metadata and controls
85 lines (72 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Test stub for typing module that includes TypedDict related things.
#
# Use [typing fixtures/typing-typeddict.pyi] to use this instead of lib-stub/typing.pyi
# in a particular test case.
#
# Many of the definitions have special handling in the type checker, so they
# can just be initialized to anything.
from abc import ABCMeta
cast = 0
assert_type = 0
overload = 0
Any = object()
Union = 0
Optional = 0
TypeVar = 0
Generic = 0
Protocol = 0
Tuple = 0
Callable = 0
NamedTuple = 0
Final = 0
Literal = 0
TypedDict = 0
NoReturn = 0
NewType = 0
Required = 0
NotRequired = 0
ReadOnly = 0
Self = 0
ClassVar = 0
T = TypeVar('T')
T_co = TypeVar('T_co', covariant=True)
V = TypeVar('V')
# Note: definitions below are different from typeshed, variances are declared
# to silence the protocol variance checks. Maybe it is better to use type: ignore?
class Sized(Protocol):
def __len__(self) -> int: pass
class Iterable(Protocol[T_co]):
def __iter__(self) -> 'Iterator[T_co]': pass
class Iterator(Iterable[T_co], Protocol):
def __next__(self) -> T_co: pass
class Collection(Iterable[T_co]): pass
class Sequence(Iterable[T_co]):
def __getitem__(self, n: Any) -> T_co: pass # type: ignore[explicit-any]
class Mapping(Iterable[T], Generic[T, T_co], metaclass=ABCMeta):
def keys(self) -> Iterable[T]: pass # Approximate return type
def __getitem__(self, key: T) -> T_co: pass
@overload
def get(self, key: T, /) -> Optional[T_co]: pass
@overload
def get(self, key: T, default: T_co, /) -> T_co: pass # type: ignore[misc]
@overload
def get(self, key: T, default: V, /) -> Union[T_co, V]: pass
def values(self) -> Iterable[T_co]: pass # Approximate return type
def __len__(self) -> int: ...
def __contains__(self, arg: object) -> int: pass
class MutableMapping(Mapping[T, V], Generic[T, V], metaclass=ABCMeta):
# Other methods are not used in tests.
def clear(self) -> None: ...
# Fallback type for all typed dicts (does not exist at runtime).
class _TypedDict(Mapping[str, object]):
# Needed to make this class non-abstract. It is explicitly declared abstract in
# typeshed, but we don't want to import abc here, as it would slow down the tests.
def __iter__(self) -> Iterator[str]: ...
def copy(self: T) -> T: ...
# Using NoReturn so that only calls using the plugin hook can go through.
def setdefault(self, k: NoReturn, default: object) -> object: ...
# Mypy expects that 'default' has a type variable type.
def pop(self, k: NoReturn, default: T = ...) -> object: ...
def update(self: T, __m: T) -> None: ...
def __delitem__(self, k: NoReturn) -> None: ...
class _SpecialForm: pass