-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathtyping.pyi
292 lines (255 loc) · 10.2 KB
/
typing.pyi
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# flake8: noqa: E704
# from https://gist.github.com/WuTheFWasThat/091a17d4b5cab597dfd5d4c2d96faf09
# Stubs for pyrsistent (Python 3.6)
#
from typing import Any
from typing import Callable
from typing import Dict
from typing import Generic
from typing import Hashable
from typing import Iterator
from typing import Iterable
from typing import List
from typing import Mapping
from typing import Optional
from typing import Sequence
from typing import AbstractSet
from typing import Sized
from typing import Set
from typing import Tuple
from typing import TypeVar
from typing import Type
from typing import Union
from typing import overload
T = TypeVar('T')
KT = TypeVar('KT')
VT = TypeVar('VT')
class PMap(Mapping[KT, VT], Hashable):
def __add__(self, other: PMap[KT, VT]) -> PMap[KT, VT]: ...
def __getitem__(self, key: KT) -> VT: ...
def __getattr__(self, key: str) -> VT: ...
def __hash__(self) -> int: ...
def __iter__(self) -> Iterator[KT]: ...
def __len__(self) -> int: ...
def copy(self) -> PMap[KT, VT]: ...
def discard(self, key: KT) -> PMap[KT, VT]: ...
def evolver(self) -> PMapEvolver[KT, VT]: ...
def iteritems(self) -> Iterable[Tuple[KT, VT]]: ...
def iterkeys(self) -> Iterable[KT]: ...
def itervalues(self) -> Iterable[VT]: ...
def remove(self, key: KT) -> PMap[KT, VT]: ...
def set(self, key: KT, val: VT) -> PMap[KT, VT]: ...
def transform(self, *transformations: Any) -> PMap[KT, VT]: ...
def update(self, *args: Mapping): ...
def update_with(self, update_fn: Callable[[VT, VT], VT], *args: Mapping) -> Any: ...
class PMapEvolver(Generic[KT, VT]):
def __delitem__(self, key: KT) -> None: ...
def __getitem__(self, key: KT) -> VT: ...
def __len__(self) -> int: ...
def __setitem__(self, key: KT, val: VT) -> None: ...
def is_dirty(self) -> bool: ...
def persistent(self) -> PMap[KT, VT]: ...
def remove(self, key: KT) -> PMapEvolver[KT, VT]: ...
def set(self, key: KT, val: VT) -> PMapEvolver[KT, VT]: ...
class PVector(Sequence[T], Hashable):
def __add__(self, other: PVector[T]) -> PVector[T]: ...
@overload
def __getitem__(self, index: int) -> T: ...
@overload
def __getitem__(self, index: slice) -> PVector[T]: ...
def __hash__(self) -> int: ...
def __len__(self) -> int: ...
def __mul__(self, other: PVector[T]) -> PVector[T]: ...
def append(self, val: T) -> PVector[T]: ...
def delete(self, index: int, stop: Optional[int] = None) -> PVector[T]: ...
def evolver(self) -> PVectorEvolver[T]: ...
def extend(self, obj: Iterable[T]) -> PVector[T]: ...
def tolist(self) -> List[T]: ...
def mset(self, *args: Iterable[Union[T, int]]) -> PVector[T]: ...
def remove(self, value: T) -> PVector[T]: ...
# Not compatible with MutableSequence
def set(self, i: int, val: T) -> PVector[T]: ...
def transform(self, *transformations: Any) -> PVector[T]: ...
class PVectorEvolver(Sequence[T], Sized):
def __delitem__(self, i: Union[int, slice]) -> None: ...
@overload
def __getitem__(self, index: int) -> T: ...
# Not actually supported
@overload
def __getitem__(self, index: slice) -> PVectorEvolver[T]: ...
def __len__(self) -> int: ...
def __setitem__(self, index: int, val: T) -> None: ...
def append(self, val: T) -> PVectorEvolver[T]: ...
def delete(self, value: T) -> PVectorEvolver[T]: ...
def extend(self, obj: Iterable[T]) -> PVectorEvolver[T]: ...
def is_dirty(self) -> bool: ...
def persistent(self) -> PVector[T]: ...
def set(self, i: int, val: T) -> PVectorEvolver[T]: ...
class PSet(AbstractSet[T], Hashable):
def __contains__(self, element: object) -> bool: ...
def __hash__(self) -> int: ...
def __iter__(self) -> Iterator[T]: ...
def __len__(self) -> int: ...
def add(self, element: T) -> PSet[T]: ...
def copy(self) -> PSet[T]: ...
def difference(self, iterable: Iterable) -> PSet[T]: ...
def discard(self, element: T) -> PSet[T]: ...
def evolver(self) -> PSetEvolver[T]: ...
def intersection(self, iterable: Iterable) -> PSet[T]: ...
def issubset(self, iterable: Iterable) -> bool: ...
def issuperset(self, iterable: Iterable) -> bool: ...
def remove(self, element: T) -> PSet[T]: ...
def symmetric_difference(self, iterable: Iterable[T]) -> PSet[T]: ...
def union(self, iterable: Iterable[T]) -> PSet[T]: ...
def update(self, iterable: Iterable[T]) -> PSet[T]: ...
class PSetEvolver(Generic[T], Sized):
def __len__(self) -> int: ...
def add(self, element: T) -> PSetEvolver[T]: ...
def is_dirty(self) -> bool: ...
def persistent(self) -> PSet[T]: ...
def remove(self, element: T) -> PSetEvolver[T]: ...
class PBag(Generic[T], Sized, Hashable):
def __add__(self, other: PBag[T]) -> PBag[T]: ...
def __and__(self, other: PBag[T]) -> PBag[T]: ...
def __contains__(self, elem: object) -> bool: ...
def __hash__(self) -> int: ...
def __iter__(self) -> Iterator[T]: ...
def __len__(self) -> int: ...
def __or__(self, other: PBag[T]) -> PBag[T]: ...
def __sub__(self, other: PBag[T]) -> PBag[T]: ...
def add(self, elem: T) -> PBag[T]: ...
def count(self, elem: T) -> int: ...
def remove(self, elem: T) -> PBag[T]: ...
def update(self, iterable: Iterable[T]) -> PBag[T]: ...
class PDeque(Sequence[T], Hashable):
@overload
def __getitem__(self, index: int) -> T: ...
@overload
def __getitem__(self, index: slice) -> PDeque[T]: ...
def __hash__(self) -> int: ...
def __len__(self) -> int: ...
def __lt__(self, other: PDeque[T]) -> bool: ...
def append(self, elem: T) -> PDeque[T]: ...
def appendleft(self, elem: T) -> PDeque[T]: ...
def extend(self, iterable: Iterable[T]) -> PDeque[T]: ...
def extendleft(self, iterable: Iterable[T]) -> PDeque[T]: ...
@property
def left(self) -> T: ...
# The real return type is Integral according to what pyrsistent
# checks at runtime but mypy doesn't deal in numeric.*:
# https://github.com/python/mypy/issues/2636
@property
def maxlen(self) -> int: ...
def pop(self, count: int = 1) -> PDeque[T]: ...
def popleft(self, count: int = 1) -> PDeque[T]: ...
def remove(self, elem: T) -> PDeque[T]: ...
def reverse(self) -> PDeque[T]: ...
@property
def right(self) -> T: ...
def rotate(self, steps: int) -> PDeque[T]: ...
class PList(Sequence[T], Hashable):
@overload
def __getitem__(self, index: int) -> T: ...
@overload
def __getitem__(self, index: slice) -> PList[T]: ...
def __hash__(self) -> int: ...
def __len__(self) -> int: ...
def __lt__(self, other: PList[T]) -> bool: ...
def __gt__(self, other: PList[T]) -> bool: ...
def cons(self, elem: T) -> PList[T]: ...
@property
def first(self) -> T: ...
def mcons(self, iterable: Iterable[T]) -> PList[T]: ...
def remove(self, elem: T) -> PList[T]: ...
@property
def rest(self) -> PList[T]: ...
def reverse(self) -> PList[T]: ...
def split(self, index: int) -> Tuple[PList[T], PList[T]]: ...
T_PClass = TypeVar('T_PClass', bound='PClass')
class PClass(Hashable):
def __new__(cls, **kwargs: Any): ...
def set(self: T_PClass, *args: Any, **kwargs: Any) -> T_PClass: ...
@classmethod
def create(
cls: Type[T_PClass],
kwargs: Any,
_factory_fields: Optional[Any] = ...,
ignore_extra: bool = ...,
) -> T_PClass: ...
def serialize(self, format: Optional[Any] = ...): ...
def transform(self, *transformations: Any): ...
def __eq__(self, other: object): ...
def __ne__(self, other: object): ...
def __hash__(self): ...
def __reduce__(self): ...
def evolver(self) -> PClassEvolver: ...
def remove(self: T_PClass, name: Any) -> T_PClass: ...
class PClassEvolver:
def __init__(self, original: Any, initial_dict: Any) -> None: ...
def __getitem__(self, item: Any): ...
def set(self, key: Any, value: Any): ...
def __setitem__(self, key: Any, value: Any) -> None: ...
def remove(self, item: Any): ...
def __delitem__(self, item: Any) -> None: ...
def persistent(self) -> PClass: ...
def __getattr__(self, item: Any): ...
class CheckedPMap(PMap[KT, VT]):
__key_type__: Type[KT]
__value_type__: Type[VT]
def __new__(cls, source: Mapping[KT, VT] = ..., size: int = ...) -> CheckedPMap: ...
@classmethod
def create(cls, source_data: Mapping[KT, VT], _factory_fields: Any = ...) -> CheckedPMap[KT, VT]: ...
def serialize(self, format: Optional[Any] = ...) -> Dict[KT, VT]: ...
class CheckedPVector(PVector[T]):
__type__: Type[T]
def __new__(self, initial: Iterable[T] = ...) -> CheckedPVector: ...
@classmethod
def create(cls, source_data: Iterable[T], _factory_fields: Any = ...) -> CheckedPVector[T]: ...
def serialize(self, format: Optional[Any] = ...) -> List[T]: ...
class CheckedPSet(PSet[T]):
__type__: Type[T]
def __new__(cls, initial: Iterable[T] = ...) -> CheckedPSet: ...
@classmethod
def create(cls, source_data: Iterable[T], _factory_fields: Any = ...) -> CheckedPSet[T]: ...
def serialize(self, format: Optional[Any] = ...) -> Set[T]: ...
class InvariantException(Exception):
invariant_errors: Tuple[Any, ...] = ... # possibly nested tuple
missing_fields: Tuple[str, ...] = ...
def __init__(
self,
error_codes: Any = ...,
missing_fields: Any = ...,
*args: Any,
**kwargs: Any
) -> None: ...
class CheckedTypeError(TypeError):
source_class: Type[Any]
expected_types: Tuple[Any, ...]
actual_type: Type[Any]
actual_value: Any
def __init__(
self,
source_class: Any,
expected_types: Any,
actual_type: Any,
actual_value: Any,
*args: Any,
**kwargs: Any
) -> None: ...
class CheckedKeyTypeError(CheckedTypeError): ...
class CheckedValueTypeError(CheckedTypeError): ...
class CheckedType: ...
class PTypeError(TypeError):
source_class: Type[Any] = ...
field: str = ...
expected_types: Tuple[Any, ...] = ...
actual_type: Type[Any] = ...
def __init__(
self,
source_class: Any,
field: Any,
expected_types: Any,
actual_type: Any,
*args: Any,
**kwargs: Any
) -> None: ...