modal 1.0.5.dev2__py3-none-any.whl → 1.0.5.dev3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- modal/_clustered_functions.pyi +13 -3
- modal/_runtime/container_io_manager.pyi +222 -40
- modal/_runtime/execution_context.pyi +60 -6
- modal/_tunnel.pyi +380 -12
- modal/app.pyi +658 -48
- modal/client.pyi +224 -28
- modal/cloud_bucket_mount.pyi +192 -4
- modal/cls.pyi +442 -35
- modal/container_process.pyi +103 -14
- modal/dict.pyi +453 -51
- modal/environments.pyi +41 -9
- modal/file_io.pyi +236 -45
- modal/functions.pyi +543 -56
- modal/image.pyi +1256 -74
- modal/io_streams.pyi +342 -39
- modal/mount.pyi +261 -31
- modal/network_file_system.pyi +307 -26
- modal/object.pyi +48 -9
- modal/parallel_map.pyi +144 -14
- modal/partial_function.pyi +255 -14
- modal/proxy.pyi +28 -3
- modal/queue.pyi +447 -30
- modal/runner.pyi +160 -22
- modal/sandbox.pyi +310 -50
- modal/secret.pyi +164 -15
- modal/snapshot.pyi +25 -4
- modal/token_flow.pyi +28 -8
- modal/volume.pyi +649 -59
- {modal-1.0.5.dev2.dist-info → modal-1.0.5.dev3.dist-info}/METADATA +1 -1
- {modal-1.0.5.dev2.dist-info → modal-1.0.5.dev3.dist-info}/RECORD +35 -35
- modal_version/__init__.py +1 -1
- {modal-1.0.5.dev2.dist-info → modal-1.0.5.dev3.dist-info}/WHEEL +0 -0
- {modal-1.0.5.dev2.dist-info → modal-1.0.5.dev3.dist-info}/entry_points.txt +0 -0
- {modal-1.0.5.dev2.dist-info → modal-1.0.5.dev3.dist-info}/licenses/LICENSE +0 -0
- {modal-1.0.5.dev2.dist-info → modal-1.0.5.dev3.dist-info}/top_level.txt +0 -0
modal/dict.pyi
CHANGED
@@ -9,7 +9,50 @@ import typing_extensions
|
|
9
9
|
def _serialize_dict(data): ...
|
10
10
|
|
11
11
|
class _Dict(modal._object._Object):
|
12
|
-
|
12
|
+
"""Distributed dictionary for storage in Modal apps.
|
13
|
+
|
14
|
+
Dict contents can be essentially any object so long as they can be serialized by
|
15
|
+
`cloudpickle`. This includes other Modal objects. If writing and reading in different
|
16
|
+
environments (eg., writing locally and reading remotely), it's necessary to have the
|
17
|
+
library defining the data type installed, with compatible versions, on both sides.
|
18
|
+
Additionally, cloudpickle serialization is not guaranteed to be deterministic, so it is
|
19
|
+
generally recommended to use primitive types for keys.
|
20
|
+
|
21
|
+
**Lifetime of a Dict and its items**
|
22
|
+
|
23
|
+
An individual Dict entry will expire after 7 days of inactivity (no reads or writes). The
|
24
|
+
Dict entries are written to durable storage.
|
25
|
+
|
26
|
+
Legacy Dicts (created before 2025-05-20) will still have entries expire 30 days after being
|
27
|
+
last added. Additionally, contents are stored in memory on the Modal server and could be lost
|
28
|
+
due to unexpected server restarts. Eventually, these Dicts will be fully sunset.
|
29
|
+
|
30
|
+
**Usage**
|
31
|
+
|
32
|
+
```python
|
33
|
+
from modal import Dict
|
34
|
+
|
35
|
+
my_dict = Dict.from_name("my-persisted_dict", create_if_missing=True)
|
36
|
+
|
37
|
+
my_dict["some key"] = "some value"
|
38
|
+
my_dict[123] = 456
|
39
|
+
|
40
|
+
assert my_dict["some key"] == "some value"
|
41
|
+
assert my_dict[123] == 456
|
42
|
+
```
|
43
|
+
|
44
|
+
The `Dict` class offers a few methods for operations that are usually accomplished
|
45
|
+
in Python with operators, such as `Dict.put` and `Dict.contains`. The advantage of
|
46
|
+
these methods is that they can be safely called in an asynchronous context by using
|
47
|
+
the `.aio` suffix on the method, whereas their operator-based analogues will always
|
48
|
+
run synchronously and block the event loop.
|
49
|
+
|
50
|
+
For more examples, see the [guide](/docs/guide/dicts-and-queues#modal-dicts).
|
51
|
+
"""
|
52
|
+
def __init__(self, data={}):
|
53
|
+
"""mdmd:hidden"""
|
54
|
+
...
|
55
|
+
|
13
56
|
@classmethod
|
14
57
|
def ephemeral(
|
15
58
|
cls: type[_Dict],
|
@@ -17,7 +60,24 @@ class _Dict(modal._object._Object):
|
|
17
60
|
client: typing.Optional[modal.client._Client] = None,
|
18
61
|
environment_name: typing.Optional[str] = None,
|
19
62
|
_heartbeat_sleep: float = 300,
|
20
|
-
) -> typing.AsyncContextManager[_Dict]:
|
63
|
+
) -> typing.AsyncContextManager[_Dict]:
|
64
|
+
"""Creates a new ephemeral Dict within a context manager:
|
65
|
+
|
66
|
+
Usage:
|
67
|
+
```python
|
68
|
+
from modal import Dict
|
69
|
+
|
70
|
+
with Dict.ephemeral() as d:
|
71
|
+
d["foo"] = "bar"
|
72
|
+
```
|
73
|
+
|
74
|
+
```python notest
|
75
|
+
async with Dict.ephemeral() as d:
|
76
|
+
await d.put.aio("foo", "bar")
|
77
|
+
```
|
78
|
+
"""
|
79
|
+
...
|
80
|
+
|
21
81
|
@staticmethod
|
22
82
|
def from_name(
|
23
83
|
name: str,
|
@@ -26,7 +86,20 @@ class _Dict(modal._object._Object):
|
|
26
86
|
namespace=1,
|
27
87
|
environment_name: typing.Optional[str] = None,
|
28
88
|
create_if_missing: bool = False,
|
29
|
-
) -> _Dict:
|
89
|
+
) -> _Dict:
|
90
|
+
"""Reference a named Dict, creating if necessary.
|
91
|
+
|
92
|
+
In contrast to `modal.Dict.lookup`, this is a lazy method
|
93
|
+
that defers hydrating the local object with metadata from
|
94
|
+
Modal servers until the first time it is actually used.
|
95
|
+
|
96
|
+
```python
|
97
|
+
d = modal.Dict.from_name("my-dict", create_if_missing=True)
|
98
|
+
d[123] = 456
|
99
|
+
```
|
100
|
+
"""
|
101
|
+
...
|
102
|
+
|
30
103
|
@staticmethod
|
31
104
|
async def lookup(
|
32
105
|
name: str,
|
@@ -35,7 +108,22 @@ class _Dict(modal._object._Object):
|
|
35
108
|
client: typing.Optional[modal.client._Client] = None,
|
36
109
|
environment_name: typing.Optional[str] = None,
|
37
110
|
create_if_missing: bool = False,
|
38
|
-
) -> _Dict:
|
111
|
+
) -> _Dict:
|
112
|
+
"""mdmd:hidden
|
113
|
+
Lookup a named Dict.
|
114
|
+
|
115
|
+
DEPRECATED: This method is deprecated in favor of `modal.Dict.from_name`.
|
116
|
+
|
117
|
+
In contrast to `modal.Dict.from_name`, this is an eager method
|
118
|
+
that will hydrate the local object with metadata from Modal servers.
|
119
|
+
|
120
|
+
```python
|
121
|
+
d = modal.Dict.from_name("my-dict")
|
122
|
+
d["xyz"] = 123
|
123
|
+
```
|
124
|
+
"""
|
125
|
+
...
|
126
|
+
|
39
127
|
@staticmethod
|
40
128
|
async def delete(
|
41
129
|
name: str,
|
@@ -43,25 +131,143 @@ class _Dict(modal._object._Object):
|
|
43
131
|
client: typing.Optional[modal.client._Client] = None,
|
44
132
|
environment_name: typing.Optional[str] = None,
|
45
133
|
): ...
|
46
|
-
async def clear(self) -> None:
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
async def
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
def
|
58
|
-
|
59
|
-
|
134
|
+
async def clear(self) -> None:
|
135
|
+
"""Remove all items from the Dict."""
|
136
|
+
...
|
137
|
+
|
138
|
+
async def get(self, key: typing.Any, default: typing.Optional[typing.Any] = None) -> typing.Any:
|
139
|
+
"""Get the value associated with a key.
|
140
|
+
|
141
|
+
Returns `default` if key does not exist.
|
142
|
+
"""
|
143
|
+
...
|
144
|
+
|
145
|
+
async def contains(self, key: typing.Any) -> bool:
|
146
|
+
"""Return if a key is present."""
|
147
|
+
...
|
148
|
+
|
149
|
+
async def len(self) -> int:
|
150
|
+
"""Return the length of the Dict.
|
151
|
+
|
152
|
+
Note: This is an expensive operation and will return at most 100,000.
|
153
|
+
"""
|
154
|
+
...
|
155
|
+
|
156
|
+
async def __getitem__(self, key: typing.Any) -> typing.Any:
|
157
|
+
"""Get the value associated with a key.
|
158
|
+
|
159
|
+
Note: this function will block the event loop when called in an async context.
|
160
|
+
"""
|
161
|
+
...
|
162
|
+
|
163
|
+
async def update(self, other: typing.Optional[collections.abc.Mapping] = None, /, **kwargs) -> None:
|
164
|
+
"""Update the Dict with additional items."""
|
165
|
+
...
|
166
|
+
|
167
|
+
async def put(self, key: typing.Any, value: typing.Any, *, skip_if_exists: bool = False) -> bool:
|
168
|
+
"""Add a specific key-value pair to the Dict.
|
169
|
+
|
170
|
+
Returns True if the key-value pair was added and False if it wasn't because the key already existed and
|
171
|
+
`skip_if_exists` was set.
|
172
|
+
"""
|
173
|
+
...
|
174
|
+
|
175
|
+
async def __setitem__(self, key: typing.Any, value: typing.Any) -> None:
|
176
|
+
"""Set a specific key-value pair to the Dict.
|
177
|
+
|
178
|
+
Note: this function will block the event loop when called in an async context.
|
179
|
+
"""
|
180
|
+
...
|
181
|
+
|
182
|
+
async def pop(self, key: typing.Any) -> typing.Any:
|
183
|
+
"""Remove a key from the Dict, returning the value if it exists."""
|
184
|
+
...
|
185
|
+
|
186
|
+
async def __delitem__(self, key: typing.Any) -> typing.Any:
|
187
|
+
"""Delete a key from the Dict.
|
188
|
+
|
189
|
+
Note: this function will block the event loop when called in an async context.
|
190
|
+
"""
|
191
|
+
...
|
192
|
+
|
193
|
+
async def __contains__(self, key: typing.Any) -> bool:
|
194
|
+
"""Return if a key is present.
|
195
|
+
|
196
|
+
Note: this function will block the event loop when called in an async context.
|
197
|
+
"""
|
198
|
+
...
|
199
|
+
|
200
|
+
def keys(self) -> collections.abc.AsyncIterator[typing.Any]:
|
201
|
+
"""Return an iterator over the keys in this Dict.
|
202
|
+
|
203
|
+
Note that (unlike with Python dicts) the return value is a simple iterator,
|
204
|
+
and results are unordered.
|
205
|
+
"""
|
206
|
+
...
|
207
|
+
|
208
|
+
def values(self) -> collections.abc.AsyncIterator[typing.Any]:
|
209
|
+
"""Return an iterator over the values in this Dict.
|
210
|
+
|
211
|
+
Note that (unlike with Python dicts) the return value is a simple iterator,
|
212
|
+
and results are unordered.
|
213
|
+
"""
|
214
|
+
...
|
215
|
+
|
216
|
+
def items(self) -> collections.abc.AsyncIterator[tuple[typing.Any, typing.Any]]:
|
217
|
+
"""Return an iterator over the (key, value) tuples in this Dict.
|
218
|
+
|
219
|
+
Note that (unlike with Python dicts) the return value is a simple iterator,
|
220
|
+
and results are unordered.
|
221
|
+
"""
|
222
|
+
...
|
60
223
|
|
61
224
|
SUPERSELF = typing.TypeVar("SUPERSELF", covariant=True)
|
62
225
|
|
63
226
|
class Dict(modal.object.Object):
|
64
|
-
|
227
|
+
"""Distributed dictionary for storage in Modal apps.
|
228
|
+
|
229
|
+
Dict contents can be essentially any object so long as they can be serialized by
|
230
|
+
`cloudpickle`. This includes other Modal objects. If writing and reading in different
|
231
|
+
environments (eg., writing locally and reading remotely), it's necessary to have the
|
232
|
+
library defining the data type installed, with compatible versions, on both sides.
|
233
|
+
Additionally, cloudpickle serialization is not guaranteed to be deterministic, so it is
|
234
|
+
generally recommended to use primitive types for keys.
|
235
|
+
|
236
|
+
**Lifetime of a Dict and its items**
|
237
|
+
|
238
|
+
An individual Dict entry will expire after 7 days of inactivity (no reads or writes). The
|
239
|
+
Dict entries are written to durable storage.
|
240
|
+
|
241
|
+
Legacy Dicts (created before 2025-05-20) will still have entries expire 30 days after being
|
242
|
+
last added. Additionally, contents are stored in memory on the Modal server and could be lost
|
243
|
+
due to unexpected server restarts. Eventually, these Dicts will be fully sunset.
|
244
|
+
|
245
|
+
**Usage**
|
246
|
+
|
247
|
+
```python
|
248
|
+
from modal import Dict
|
249
|
+
|
250
|
+
my_dict = Dict.from_name("my-persisted_dict", create_if_missing=True)
|
251
|
+
|
252
|
+
my_dict["some key"] = "some value"
|
253
|
+
my_dict[123] = 456
|
254
|
+
|
255
|
+
assert my_dict["some key"] == "some value"
|
256
|
+
assert my_dict[123] == 456
|
257
|
+
```
|
258
|
+
|
259
|
+
The `Dict` class offers a few methods for operations that are usually accomplished
|
260
|
+
in Python with operators, such as `Dict.put` and `Dict.contains`. The advantage of
|
261
|
+
these methods is that they can be safely called in an asynchronous context by using
|
262
|
+
the `.aio` suffix on the method, whereas their operator-based analogues will always
|
263
|
+
run synchronously and block the event loop.
|
264
|
+
|
265
|
+
For more examples, see the [guide](/docs/guide/dicts-and-queues#modal-dicts).
|
266
|
+
"""
|
267
|
+
def __init__(self, data={}):
|
268
|
+
"""mdmd:hidden"""
|
269
|
+
...
|
270
|
+
|
65
271
|
@classmethod
|
66
272
|
def ephemeral(
|
67
273
|
cls: type[Dict],
|
@@ -69,7 +275,24 @@ class Dict(modal.object.Object):
|
|
69
275
|
client: typing.Optional[modal.client.Client] = None,
|
70
276
|
environment_name: typing.Optional[str] = None,
|
71
277
|
_heartbeat_sleep: float = 300,
|
72
|
-
) -> synchronicity.combined_types.AsyncAndBlockingContextManager[Dict]:
|
278
|
+
) -> synchronicity.combined_types.AsyncAndBlockingContextManager[Dict]:
|
279
|
+
"""Creates a new ephemeral Dict within a context manager:
|
280
|
+
|
281
|
+
Usage:
|
282
|
+
```python
|
283
|
+
from modal import Dict
|
284
|
+
|
285
|
+
with Dict.ephemeral() as d:
|
286
|
+
d["foo"] = "bar"
|
287
|
+
```
|
288
|
+
|
289
|
+
```python notest
|
290
|
+
async with Dict.ephemeral() as d:
|
291
|
+
await d.put.aio("foo", "bar")
|
292
|
+
```
|
293
|
+
"""
|
294
|
+
...
|
295
|
+
|
73
296
|
@staticmethod
|
74
297
|
def from_name(
|
75
298
|
name: str,
|
@@ -78,7 +301,19 @@ class Dict(modal.object.Object):
|
|
78
301
|
namespace=1,
|
79
302
|
environment_name: typing.Optional[str] = None,
|
80
303
|
create_if_missing: bool = False,
|
81
|
-
) -> Dict:
|
304
|
+
) -> Dict:
|
305
|
+
"""Reference a named Dict, creating if necessary.
|
306
|
+
|
307
|
+
In contrast to `modal.Dict.lookup`, this is a lazy method
|
308
|
+
that defers hydrating the local object with metadata from
|
309
|
+
Modal servers until the first time it is actually used.
|
310
|
+
|
311
|
+
```python
|
312
|
+
d = modal.Dict.from_name("my-dict", create_if_missing=True)
|
313
|
+
d[123] = 456
|
314
|
+
```
|
315
|
+
"""
|
316
|
+
...
|
82
317
|
|
83
318
|
class __lookup_spec(typing_extensions.Protocol):
|
84
319
|
def __call__(
|
@@ -90,7 +325,22 @@ class Dict(modal.object.Object):
|
|
90
325
|
client: typing.Optional[modal.client.Client] = None,
|
91
326
|
environment_name: typing.Optional[str] = None,
|
92
327
|
create_if_missing: bool = False,
|
93
|
-
) -> Dict:
|
328
|
+
) -> Dict:
|
329
|
+
"""mdmd:hidden
|
330
|
+
Lookup a named Dict.
|
331
|
+
|
332
|
+
DEPRECATED: This method is deprecated in favor of `modal.Dict.from_name`.
|
333
|
+
|
334
|
+
In contrast to `modal.Dict.from_name`, this is an eager method
|
335
|
+
that will hydrate the local object with metadata from Modal servers.
|
336
|
+
|
337
|
+
```python
|
338
|
+
d = modal.Dict.from_name("my-dict")
|
339
|
+
d["xyz"] = 123
|
340
|
+
```
|
341
|
+
"""
|
342
|
+
...
|
343
|
+
|
94
344
|
async def aio(
|
95
345
|
self,
|
96
346
|
/,
|
@@ -100,7 +350,21 @@ class Dict(modal.object.Object):
|
|
100
350
|
client: typing.Optional[modal.client.Client] = None,
|
101
351
|
environment_name: typing.Optional[str] = None,
|
102
352
|
create_if_missing: bool = False,
|
103
|
-
) -> Dict:
|
353
|
+
) -> Dict:
|
354
|
+
"""mdmd:hidden
|
355
|
+
Lookup a named Dict.
|
356
|
+
|
357
|
+
DEPRECATED: This method is deprecated in favor of `modal.Dict.from_name`.
|
358
|
+
|
359
|
+
In contrast to `modal.Dict.from_name`, this is an eager method
|
360
|
+
that will hydrate the local object with metadata from Modal servers.
|
361
|
+
|
362
|
+
```python
|
363
|
+
d = modal.Dict.from_name("my-dict")
|
364
|
+
d["xyz"] = 123
|
365
|
+
```
|
366
|
+
"""
|
367
|
+
...
|
104
368
|
|
105
369
|
lookup: __lookup_spec
|
106
370
|
|
@@ -125,85 +389,223 @@ class Dict(modal.object.Object):
|
|
125
389
|
delete: __delete_spec
|
126
390
|
|
127
391
|
class __clear_spec(typing_extensions.Protocol[SUPERSELF]):
|
128
|
-
def __call__(self, /) -> None:
|
129
|
-
|
392
|
+
def __call__(self, /) -> None:
|
393
|
+
"""Remove all items from the Dict."""
|
394
|
+
...
|
395
|
+
|
396
|
+
async def aio(self, /) -> None:
|
397
|
+
"""Remove all items from the Dict."""
|
398
|
+
...
|
130
399
|
|
131
400
|
clear: __clear_spec[typing_extensions.Self]
|
132
401
|
|
133
402
|
class __get_spec(typing_extensions.Protocol[SUPERSELF]):
|
134
|
-
def __call__(self, /, key: typing.Any, default: typing.Optional[typing.Any] = None) -> typing.Any:
|
135
|
-
|
403
|
+
def __call__(self, /, key: typing.Any, default: typing.Optional[typing.Any] = None) -> typing.Any:
|
404
|
+
"""Get the value associated with a key.
|
405
|
+
|
406
|
+
Returns `default` if key does not exist.
|
407
|
+
"""
|
408
|
+
...
|
409
|
+
|
410
|
+
async def aio(self, /, key: typing.Any, default: typing.Optional[typing.Any] = None) -> typing.Any:
|
411
|
+
"""Get the value associated with a key.
|
412
|
+
|
413
|
+
Returns `default` if key does not exist.
|
414
|
+
"""
|
415
|
+
...
|
136
416
|
|
137
417
|
get: __get_spec[typing_extensions.Self]
|
138
418
|
|
139
419
|
class __contains_spec(typing_extensions.Protocol[SUPERSELF]):
|
140
|
-
def __call__(self, /, key: typing.Any) -> bool:
|
141
|
-
|
420
|
+
def __call__(self, /, key: typing.Any) -> bool:
|
421
|
+
"""Return if a key is present."""
|
422
|
+
...
|
423
|
+
|
424
|
+
async def aio(self, /, key: typing.Any) -> bool:
|
425
|
+
"""Return if a key is present."""
|
426
|
+
...
|
142
427
|
|
143
428
|
contains: __contains_spec[typing_extensions.Self]
|
144
429
|
|
145
430
|
class __len_spec(typing_extensions.Protocol[SUPERSELF]):
|
146
|
-
def __call__(self, /) -> int:
|
147
|
-
|
431
|
+
def __call__(self, /) -> int:
|
432
|
+
"""Return the length of the Dict.
|
433
|
+
|
434
|
+
Note: This is an expensive operation and will return at most 100,000.
|
435
|
+
"""
|
436
|
+
...
|
437
|
+
|
438
|
+
async def aio(self, /) -> int:
|
439
|
+
"""Return the length of the Dict.
|
440
|
+
|
441
|
+
Note: This is an expensive operation and will return at most 100,000.
|
442
|
+
"""
|
443
|
+
...
|
148
444
|
|
149
445
|
len: __len_spec[typing_extensions.Self]
|
150
446
|
|
151
447
|
class ____getitem___spec(typing_extensions.Protocol[SUPERSELF]):
|
152
|
-
def __call__(self, /, key: typing.Any) -> typing.Any:
|
153
|
-
|
448
|
+
def __call__(self, /, key: typing.Any) -> typing.Any:
|
449
|
+
"""Get the value associated with a key.
|
450
|
+
|
451
|
+
Note: this function will block the event loop when called in an async context.
|
452
|
+
"""
|
453
|
+
...
|
454
|
+
|
455
|
+
async def aio(self, /, key: typing.Any) -> typing.Any:
|
456
|
+
"""Get the value associated with a key.
|
457
|
+
|
458
|
+
Note: this function will block the event loop when called in an async context.
|
459
|
+
"""
|
460
|
+
...
|
154
461
|
|
155
462
|
__getitem__: ____getitem___spec[typing_extensions.Self]
|
156
463
|
|
157
464
|
class __update_spec(typing_extensions.Protocol[SUPERSELF]):
|
158
|
-
def __call__(self, other: typing.Optional[collections.abc.Mapping] = None, /, **kwargs) -> None:
|
159
|
-
|
465
|
+
def __call__(self, other: typing.Optional[collections.abc.Mapping] = None, /, **kwargs) -> None:
|
466
|
+
"""Update the Dict with additional items."""
|
467
|
+
...
|
468
|
+
|
469
|
+
async def aio(self, other: typing.Optional[collections.abc.Mapping] = None, /, **kwargs) -> None:
|
470
|
+
"""Update the Dict with additional items."""
|
471
|
+
...
|
160
472
|
|
161
473
|
update: __update_spec[typing_extensions.Self]
|
162
474
|
|
163
475
|
class __put_spec(typing_extensions.Protocol[SUPERSELF]):
|
164
|
-
def __call__(self, /, key: typing.Any, value: typing.Any, *, skip_if_exists: bool = False) -> bool:
|
165
|
-
|
476
|
+
def __call__(self, /, key: typing.Any, value: typing.Any, *, skip_if_exists: bool = False) -> bool:
|
477
|
+
"""Add a specific key-value pair to the Dict.
|
478
|
+
|
479
|
+
Returns True if the key-value pair was added and False if it wasn't because the key already existed and
|
480
|
+
`skip_if_exists` was set.
|
481
|
+
"""
|
482
|
+
...
|
483
|
+
|
484
|
+
async def aio(self, /, key: typing.Any, value: typing.Any, *, skip_if_exists: bool = False) -> bool:
|
485
|
+
"""Add a specific key-value pair to the Dict.
|
486
|
+
|
487
|
+
Returns True if the key-value pair was added and False if it wasn't because the key already existed and
|
488
|
+
`skip_if_exists` was set.
|
489
|
+
"""
|
490
|
+
...
|
166
491
|
|
167
492
|
put: __put_spec[typing_extensions.Self]
|
168
493
|
|
169
494
|
class ____setitem___spec(typing_extensions.Protocol[SUPERSELF]):
|
170
|
-
def __call__(self, /, key: typing.Any, value: typing.Any) -> None:
|
171
|
-
|
495
|
+
def __call__(self, /, key: typing.Any, value: typing.Any) -> None:
|
496
|
+
"""Set a specific key-value pair to the Dict.
|
497
|
+
|
498
|
+
Note: this function will block the event loop when called in an async context.
|
499
|
+
"""
|
500
|
+
...
|
501
|
+
|
502
|
+
async def aio(self, /, key: typing.Any, value: typing.Any) -> None:
|
503
|
+
"""Set a specific key-value pair to the Dict.
|
504
|
+
|
505
|
+
Note: this function will block the event loop when called in an async context.
|
506
|
+
"""
|
507
|
+
...
|
172
508
|
|
173
509
|
__setitem__: ____setitem___spec[typing_extensions.Self]
|
174
510
|
|
175
511
|
class __pop_spec(typing_extensions.Protocol[SUPERSELF]):
|
176
|
-
def __call__(self, /, key: typing.Any) -> typing.Any:
|
177
|
-
|
512
|
+
def __call__(self, /, key: typing.Any) -> typing.Any:
|
513
|
+
"""Remove a key from the Dict, returning the value if it exists."""
|
514
|
+
...
|
515
|
+
|
516
|
+
async def aio(self, /, key: typing.Any) -> typing.Any:
|
517
|
+
"""Remove a key from the Dict, returning the value if it exists."""
|
518
|
+
...
|
178
519
|
|
179
520
|
pop: __pop_spec[typing_extensions.Self]
|
180
521
|
|
181
522
|
class ____delitem___spec(typing_extensions.Protocol[SUPERSELF]):
|
182
|
-
def __call__(self, /, key: typing.Any) -> typing.Any:
|
183
|
-
|
523
|
+
def __call__(self, /, key: typing.Any) -> typing.Any:
|
524
|
+
"""Delete a key from the Dict.
|
525
|
+
|
526
|
+
Note: this function will block the event loop when called in an async context.
|
527
|
+
"""
|
528
|
+
...
|
529
|
+
|
530
|
+
async def aio(self, /, key: typing.Any) -> typing.Any:
|
531
|
+
"""Delete a key from the Dict.
|
532
|
+
|
533
|
+
Note: this function will block the event loop when called in an async context.
|
534
|
+
"""
|
535
|
+
...
|
184
536
|
|
185
537
|
__delitem__: ____delitem___spec[typing_extensions.Self]
|
186
538
|
|
187
539
|
class ____contains___spec(typing_extensions.Protocol[SUPERSELF]):
|
188
|
-
def __call__(self, /, key: typing.Any) -> bool:
|
189
|
-
|
540
|
+
def __call__(self, /, key: typing.Any) -> bool:
|
541
|
+
"""Return if a key is present.
|
542
|
+
|
543
|
+
Note: this function will block the event loop when called in an async context.
|
544
|
+
"""
|
545
|
+
...
|
546
|
+
|
547
|
+
async def aio(self, /, key: typing.Any) -> bool:
|
548
|
+
"""Return if a key is present.
|
549
|
+
|
550
|
+
Note: this function will block the event loop when called in an async context.
|
551
|
+
"""
|
552
|
+
...
|
190
553
|
|
191
554
|
__contains__: ____contains___spec[typing_extensions.Self]
|
192
555
|
|
193
556
|
class __keys_spec(typing_extensions.Protocol[SUPERSELF]):
|
194
|
-
def __call__(self, /) -> typing.Iterator[typing.Any]:
|
195
|
-
|
557
|
+
def __call__(self, /) -> typing.Iterator[typing.Any]:
|
558
|
+
"""Return an iterator over the keys in this Dict.
|
559
|
+
|
560
|
+
Note that (unlike with Python dicts) the return value is a simple iterator,
|
561
|
+
and results are unordered.
|
562
|
+
"""
|
563
|
+
...
|
564
|
+
|
565
|
+
def aio(self, /) -> collections.abc.AsyncIterator[typing.Any]:
|
566
|
+
"""Return an iterator over the keys in this Dict.
|
567
|
+
|
568
|
+
Note that (unlike with Python dicts) the return value is a simple iterator,
|
569
|
+
and results are unordered.
|
570
|
+
"""
|
571
|
+
...
|
196
572
|
|
197
573
|
keys: __keys_spec[typing_extensions.Self]
|
198
574
|
|
199
575
|
class __values_spec(typing_extensions.Protocol[SUPERSELF]):
|
200
|
-
def __call__(self, /) -> typing.Iterator[typing.Any]:
|
201
|
-
|
576
|
+
def __call__(self, /) -> typing.Iterator[typing.Any]:
|
577
|
+
"""Return an iterator over the values in this Dict.
|
578
|
+
|
579
|
+
Note that (unlike with Python dicts) the return value is a simple iterator,
|
580
|
+
and results are unordered.
|
581
|
+
"""
|
582
|
+
...
|
583
|
+
|
584
|
+
def aio(self, /) -> collections.abc.AsyncIterator[typing.Any]:
|
585
|
+
"""Return an iterator over the values in this Dict.
|
586
|
+
|
587
|
+
Note that (unlike with Python dicts) the return value is a simple iterator,
|
588
|
+
and results are unordered.
|
589
|
+
"""
|
590
|
+
...
|
202
591
|
|
203
592
|
values: __values_spec[typing_extensions.Self]
|
204
593
|
|
205
594
|
class __items_spec(typing_extensions.Protocol[SUPERSELF]):
|
206
|
-
def __call__(self, /) -> typing.Iterator[tuple[typing.Any, typing.Any]]:
|
207
|
-
|
595
|
+
def __call__(self, /) -> typing.Iterator[tuple[typing.Any, typing.Any]]:
|
596
|
+
"""Return an iterator over the (key, value) tuples in this Dict.
|
597
|
+
|
598
|
+
Note that (unlike with Python dicts) the return value is a simple iterator,
|
599
|
+
and results are unordered.
|
600
|
+
"""
|
601
|
+
...
|
602
|
+
|
603
|
+
def aio(self, /) -> collections.abc.AsyncIterator[tuple[typing.Any, typing.Any]]:
|
604
|
+
"""Return an iterator over the (key, value) tuples in this Dict.
|
605
|
+
|
606
|
+
Note that (unlike with Python dicts) the return value is a simple iterator,
|
607
|
+
and results are unordered.
|
608
|
+
"""
|
609
|
+
...
|
208
610
|
|
209
611
|
items: __items_spec[typing_extensions.Self]
|