modal 0.72.37__py3-none-any.whl → 0.72.39__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/functions.pyi CHANGED
@@ -134,6 +134,8 @@ ReturnType = typing.TypeVar("ReturnType", covariant=True)
134
134
 
135
135
  OriginalReturnType = typing.TypeVar("OriginalReturnType", covariant=True)
136
136
 
137
+ SUPERSELF = typing.TypeVar("SUPERSELF", covariant=True)
138
+
137
139
  class _Function(typing.Generic[P, ReturnType, OriginalReturnType], modal._object._Object):
138
140
  _info: typing.Optional[modal._utils.function_utils.FunctionInfo]
139
141
  _serve_mounts: frozenset[modal.mount._Mount]
@@ -144,7 +146,7 @@ class _Function(typing.Generic[P, ReturnType, OriginalReturnType], modal._object
144
146
  _is_method: bool
145
147
  _spec: typing.Optional[_FunctionSpec]
146
148
  _tag: str
147
- _raw_f: typing.Optional[typing.Callable[..., typing.Any]]
149
+ _raw_f: typing.Optional[collections.abc.Callable[..., typing.Any]]
148
150
  _build_args: dict
149
151
  _is_generator: typing.Optional[bool]
150
152
  _cluster_size: typing.Optional[int]
@@ -255,10 +257,10 @@ class _Function(typing.Generic[P, ReturnType, OriginalReturnType], modal._object
255
257
  def local(self, *args: P.args, **kwargs: P.kwargs) -> OriginalReturnType: ...
256
258
  async def _experimental_spawn(self, *args: P.args, **kwargs: P.kwargs) -> _FunctionCall[ReturnType]: ...
257
259
  async def spawn(self, *args: P.args, **kwargs: P.kwargs) -> _FunctionCall[ReturnType]: ...
258
- def get_raw_f(self) -> typing.Callable[..., typing.Any]: ...
260
+ def get_raw_f(self) -> collections.abc.Callable[..., typing.Any]: ...
259
261
  async def get_current_stats(self) -> FunctionStats: ...
260
262
 
261
- class __map_spec(typing_extensions.Protocol):
263
+ class __map_spec(typing_extensions.Protocol[SUPERSELF]):
262
264
  def __call__(
263
265
  self, *input_iterators, kwargs={}, order_outputs: bool = True, return_exceptions: bool = False
264
266
  ) -> modal._utils.async_utils.AsyncOrSyncIterable: ...
@@ -270,9 +272,9 @@ class _Function(typing.Generic[P, ReturnType, OriginalReturnType], modal._object
270
272
  return_exceptions: bool = False,
271
273
  ) -> typing.AsyncGenerator[typing.Any, None]: ...
272
274
 
273
- map: __map_spec
275
+ map: __map_spec[typing_extensions.Self]
274
276
 
275
- class __starmap_spec(typing_extensions.Protocol):
277
+ class __starmap_spec(typing_extensions.Protocol[SUPERSELF]):
276
278
  def __call__(
277
279
  self,
278
280
  input_iterator: typing.Iterable[typing.Sequence[typing.Any]],
@@ -290,13 +292,13 @@ class _Function(typing.Generic[P, ReturnType, OriginalReturnType], modal._object
290
292
  return_exceptions: bool = False,
291
293
  ) -> typing.AsyncIterable[typing.Any]: ...
292
294
 
293
- starmap: __starmap_spec
295
+ starmap: __starmap_spec[typing_extensions.Self]
294
296
 
295
- class __for_each_spec(typing_extensions.Protocol):
297
+ class __for_each_spec(typing_extensions.Protocol[SUPERSELF]):
296
298
  def __call__(self, *input_iterators, kwargs={}, ignore_exceptions: bool = False): ...
297
299
  async def aio(self, *input_iterators, kwargs={}, ignore_exceptions: bool = False): ...
298
300
 
299
- for_each: __for_each_spec
301
+ for_each: __for_each_spec[typing_extensions.Self]
300
302
 
301
303
  ReturnType_INNER = typing.TypeVar("ReturnType_INNER", covariant=True)
302
304
 
@@ -312,7 +314,7 @@ class Function(typing.Generic[P, ReturnType, OriginalReturnType], modal.object.O
312
314
  _is_method: bool
313
315
  _spec: typing.Optional[_FunctionSpec]
314
316
  _tag: str
315
- _raw_f: typing.Optional[typing.Callable[..., typing.Any]]
317
+ _raw_f: typing.Optional[collections.abc.Callable[..., typing.Any]]
316
318
  _build_args: dict
317
319
  _is_generator: typing.Optional[bool]
318
320
  _cluster_size: typing.Optional[int]
@@ -376,11 +378,11 @@ class Function(typing.Generic[P, ReturnType, OriginalReturnType], modal.object.O
376
378
  kwargs: dict[str, typing.Any],
377
379
  ) -> Function: ...
378
380
 
379
- class __keep_warm_spec(typing_extensions.Protocol):
381
+ class __keep_warm_spec(typing_extensions.Protocol[SUPERSELF]):
380
382
  def __call__(self, warm_pool_size: int) -> None: ...
381
383
  async def aio(self, warm_pool_size: int) -> None: ...
382
384
 
383
- keep_warm: __keep_warm_spec
385
+ keep_warm: __keep_warm_spec[typing_extensions.Self]
384
386
 
385
387
  @classmethod
386
388
  def from_name(
@@ -429,7 +431,7 @@ class Function(typing.Generic[P, ReturnType, OriginalReturnType], modal.object.O
429
431
  @property
430
432
  def cluster_size(self) -> int: ...
431
433
 
432
- class ___map_spec(typing_extensions.Protocol):
434
+ class ___map_spec(typing_extensions.Protocol[SUPERSELF]):
433
435
  def __call__(
434
436
  self, input_queue: modal.parallel_map.SynchronizedQueue, order_outputs: bool, return_exceptions: bool
435
437
  ) -> typing.Generator[typing.Any, None, None]: ...
@@ -437,70 +439,70 @@ class Function(typing.Generic[P, ReturnType, OriginalReturnType], modal.object.O
437
439
  self, input_queue: modal.parallel_map.SynchronizedQueue, order_outputs: bool, return_exceptions: bool
438
440
  ) -> collections.abc.AsyncGenerator[typing.Any, None]: ...
439
441
 
440
- _map: ___map_spec
442
+ _map: ___map_spec[typing_extensions.Self]
441
443
 
442
- class ___call_function_spec(typing_extensions.Protocol[ReturnType_INNER]):
444
+ class ___call_function_spec(typing_extensions.Protocol[ReturnType_INNER, SUPERSELF]):
443
445
  def __call__(self, args, kwargs) -> ReturnType_INNER: ...
444
446
  async def aio(self, args, kwargs) -> ReturnType_INNER: ...
445
447
 
446
- _call_function: ___call_function_spec[ReturnType]
448
+ _call_function: ___call_function_spec[ReturnType, typing_extensions.Self]
447
449
 
448
- class ___call_function_nowait_spec(typing_extensions.Protocol):
450
+ class ___call_function_nowait_spec(typing_extensions.Protocol[SUPERSELF]):
449
451
  def __call__(self, args, kwargs, function_call_invocation_type: int) -> _Invocation: ...
450
452
  async def aio(self, args, kwargs, function_call_invocation_type: int) -> _Invocation: ...
451
453
 
452
- _call_function_nowait: ___call_function_nowait_spec
454
+ _call_function_nowait: ___call_function_nowait_spec[typing_extensions.Self]
453
455
 
454
- class ___call_generator_spec(typing_extensions.Protocol):
456
+ class ___call_generator_spec(typing_extensions.Protocol[SUPERSELF]):
455
457
  def __call__(self, args, kwargs): ...
456
458
  def aio(self, args, kwargs): ...
457
459
 
458
- _call_generator: ___call_generator_spec
460
+ _call_generator: ___call_generator_spec[typing_extensions.Self]
459
461
 
460
- class ___call_generator_nowait_spec(typing_extensions.Protocol):
462
+ class ___call_generator_nowait_spec(typing_extensions.Protocol[SUPERSELF]):
461
463
  def __call__(self, args, kwargs): ...
462
464
  async def aio(self, args, kwargs): ...
463
465
 
464
- _call_generator_nowait: ___call_generator_nowait_spec
466
+ _call_generator_nowait: ___call_generator_nowait_spec[typing_extensions.Self]
465
467
 
466
- class __remote_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER]):
468
+ class __remote_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER, SUPERSELF]):
467
469
  def __call__(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> ReturnType_INNER: ...
468
470
  async def aio(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> ReturnType_INNER: ...
469
471
 
470
- remote: __remote_spec[P, ReturnType]
472
+ remote: __remote_spec[ReturnType, P, typing_extensions.Self]
471
473
 
472
- class __remote_gen_spec(typing_extensions.Protocol):
474
+ class __remote_gen_spec(typing_extensions.Protocol[SUPERSELF]):
473
475
  def __call__(self, *args, **kwargs) -> typing.Generator[typing.Any, None, None]: ...
474
476
  def aio(self, *args, **kwargs) -> collections.abc.AsyncGenerator[typing.Any, None]: ...
475
477
 
476
- remote_gen: __remote_gen_spec
478
+ remote_gen: __remote_gen_spec[typing_extensions.Self]
477
479
 
478
480
  def _is_local(self): ...
479
481
  def _get_info(self) -> modal._utils.function_utils.FunctionInfo: ...
480
482
  def _get_obj(self) -> typing.Optional[modal.cls.Obj]: ...
481
483
  def local(self, *args: P.args, **kwargs: P.kwargs) -> OriginalReturnType: ...
482
484
 
483
- class ___experimental_spawn_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER]):
485
+ class ___experimental_spawn_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER, SUPERSELF]):
484
486
  def __call__(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]: ...
485
487
  async def aio(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]: ...
486
488
 
487
- _experimental_spawn: ___experimental_spawn_spec[P, ReturnType]
489
+ _experimental_spawn: ___experimental_spawn_spec[ReturnType, P, typing_extensions.Self]
488
490
 
489
- class __spawn_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER]):
491
+ class __spawn_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER, SUPERSELF]):
490
492
  def __call__(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]: ...
491
493
  async def aio(self, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]: ...
492
494
 
493
- spawn: __spawn_spec[P, ReturnType]
495
+ spawn: __spawn_spec[ReturnType, P, typing_extensions.Self]
494
496
 
495
- def get_raw_f(self) -> typing.Callable[..., typing.Any]: ...
497
+ def get_raw_f(self) -> collections.abc.Callable[..., typing.Any]: ...
496
498
 
497
- class __get_current_stats_spec(typing_extensions.Protocol):
499
+ class __get_current_stats_spec(typing_extensions.Protocol[SUPERSELF]):
498
500
  def __call__(self) -> FunctionStats: ...
499
501
  async def aio(self) -> FunctionStats: ...
500
502
 
501
- get_current_stats: __get_current_stats_spec
503
+ get_current_stats: __get_current_stats_spec[typing_extensions.Self]
502
504
 
503
- class __map_spec(typing_extensions.Protocol):
505
+ class __map_spec(typing_extensions.Protocol[SUPERSELF]):
504
506
  def __call__(
505
507
  self, *input_iterators, kwargs={}, order_outputs: bool = True, return_exceptions: bool = False
506
508
  ) -> modal._utils.async_utils.AsyncOrSyncIterable: ...
@@ -512,9 +514,9 @@ class Function(typing.Generic[P, ReturnType, OriginalReturnType], modal.object.O
512
514
  return_exceptions: bool = False,
513
515
  ) -> typing.AsyncGenerator[typing.Any, None]: ...
514
516
 
515
- map: __map_spec
517
+ map: __map_spec[typing_extensions.Self]
516
518
 
517
- class __starmap_spec(typing_extensions.Protocol):
519
+ class __starmap_spec(typing_extensions.Protocol[SUPERSELF]):
518
520
  def __call__(
519
521
  self,
520
522
  input_iterator: typing.Iterable[typing.Sequence[typing.Any]],
@@ -532,13 +534,13 @@ class Function(typing.Generic[P, ReturnType, OriginalReturnType], modal.object.O
532
534
  return_exceptions: bool = False,
533
535
  ) -> typing.AsyncIterable[typing.Any]: ...
534
536
 
535
- starmap: __starmap_spec
537
+ starmap: __starmap_spec[typing_extensions.Self]
536
538
 
537
- class __for_each_spec(typing_extensions.Protocol):
539
+ class __for_each_spec(typing_extensions.Protocol[SUPERSELF]):
538
540
  def __call__(self, *input_iterators, kwargs={}, ignore_exceptions: bool = False): ...
539
541
  async def aio(self, *input_iterators, kwargs={}, ignore_exceptions: bool = False): ...
540
542
 
541
- for_each: __for_each_spec
543
+ for_each: __for_each_spec[typing_extensions.Self]
542
544
 
543
545
  class _FunctionCall(typing.Generic[ReturnType], modal._object._Object):
544
546
  _is_generator: bool
@@ -559,29 +561,29 @@ class FunctionCall(typing.Generic[ReturnType], modal.object.Object):
559
561
  def __init__(self, *args, **kwargs): ...
560
562
  def _invocation(self): ...
561
563
 
562
- class __get_spec(typing_extensions.Protocol[ReturnType_INNER]):
564
+ class __get_spec(typing_extensions.Protocol[ReturnType_INNER, SUPERSELF]):
563
565
  def __call__(self, timeout: typing.Optional[float] = None) -> ReturnType_INNER: ...
564
566
  async def aio(self, timeout: typing.Optional[float] = None) -> ReturnType_INNER: ...
565
567
 
566
- get: __get_spec[ReturnType]
568
+ get: __get_spec[ReturnType, typing_extensions.Self]
567
569
 
568
- class __get_gen_spec(typing_extensions.Protocol):
570
+ class __get_gen_spec(typing_extensions.Protocol[SUPERSELF]):
569
571
  def __call__(self) -> typing.Generator[typing.Any, None, None]: ...
570
572
  def aio(self) -> collections.abc.AsyncGenerator[typing.Any, None]: ...
571
573
 
572
- get_gen: __get_gen_spec
574
+ get_gen: __get_gen_spec[typing_extensions.Self]
573
575
 
574
- class __get_call_graph_spec(typing_extensions.Protocol):
576
+ class __get_call_graph_spec(typing_extensions.Protocol[SUPERSELF]):
575
577
  def __call__(self) -> list[modal.call_graph.InputInfo]: ...
576
578
  async def aio(self) -> list[modal.call_graph.InputInfo]: ...
577
579
 
578
- get_call_graph: __get_call_graph_spec
580
+ get_call_graph: __get_call_graph_spec[typing_extensions.Self]
579
581
 
580
- class __cancel_spec(typing_extensions.Protocol):
582
+ class __cancel_spec(typing_extensions.Protocol[SUPERSELF]):
581
583
  def __call__(self, terminate_containers: bool = False): ...
582
584
  async def aio(self, terminate_containers: bool = False): ...
583
585
 
584
- cancel: __cancel_spec
586
+ cancel: __cancel_spec[typing_extensions.Self]
585
587
 
586
588
  class __from_id_spec(typing_extensions.Protocol):
587
589
  def __call__(
modal/image.pyi CHANGED
@@ -53,11 +53,11 @@ def _get_image_builder_version(
53
53
  ) -> typing.Literal["2023.12", "2024.04", "2024.10"]: ...
54
54
  def _create_context_mount(
55
55
  docker_commands: collections.abc.Sequence[str],
56
- ignore_fn: typing.Callable[[pathlib.Path], bool],
56
+ ignore_fn: collections.abc.Callable[[pathlib.Path], bool],
57
57
  context_dir: pathlib.Path,
58
58
  ) -> typing.Optional[modal.mount._Mount]: ...
59
59
  def _create_context_mount_function(
60
- ignore: typing.Union[collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]],
60
+ ignore: typing.Union[collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]],
61
61
  dockerfile_cmds: list[str] = [],
62
62
  dockerfile_path: typing.Optional[pathlib.Path] = None,
63
63
  context_mount: typing.Optional[modal.mount._Mount] = None,
@@ -98,14 +98,16 @@ class _Image(modal._object._Object):
98
98
  *,
99
99
  base_images: typing.Optional[dict[str, _Image]] = None,
100
100
  dockerfile_function: typing.Optional[
101
- typing.Callable[[typing.Literal["2023.12", "2024.04", "2024.10"]], DockerfileSpec]
101
+ collections.abc.Callable[[typing.Literal["2023.12", "2024.04", "2024.10"]], DockerfileSpec]
102
102
  ] = None,
103
103
  secrets: typing.Optional[collections.abc.Sequence[modal.secret._Secret]] = None,
104
104
  gpu_config: typing.Optional[modal_proto.api_pb2.GPUConfig] = None,
105
105
  build_function: typing.Optional[modal.functions._Function] = None,
106
106
  build_function_input: typing.Optional[modal_proto.api_pb2.FunctionInput] = None,
107
107
  image_registry_config: typing.Optional[_ImageRegistryConfig] = None,
108
- context_mount_function: typing.Optional[typing.Callable[[], typing.Optional[modal.mount._Mount]]] = None,
108
+ context_mount_function: typing.Optional[
109
+ collections.abc.Callable[[], typing.Optional[modal.mount._Mount]]
110
+ ] = None,
109
111
  force_build: bool = False,
110
112
  _namespace: int = 1,
111
113
  _do_assert_no_mount_layers: bool = True,
@@ -120,7 +122,7 @@ class _Image(modal._object._Object):
120
122
  remote_path: str,
121
123
  *,
122
124
  copy: bool = False,
123
- ignore: typing.Union[collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]] = [],
125
+ ignore: typing.Union[collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]] = [],
124
126
  ) -> _Image: ...
125
127
  def copy_local_file(
126
128
  self, local_path: typing.Union[str, pathlib.Path], remote_path: typing.Union[str, pathlib.Path] = "./"
@@ -130,14 +132,14 @@ class _Image(modal._object._Object):
130
132
  *module_names: str,
131
133
  copy: bool = False,
132
134
  ignore: typing.Union[
133
- collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]
135
+ collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]
134
136
  ] = modal.file_pattern_matcher.NON_PYTHON_FILES,
135
137
  ) -> _Image: ...
136
138
  def copy_local_dir(
137
139
  self,
138
140
  local_path: typing.Union[str, pathlib.Path],
139
141
  remote_path: typing.Union[str, pathlib.Path] = ".",
140
- ignore: typing.Union[collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]] = [],
142
+ ignore: typing.Union[collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]] = [],
141
143
  ) -> _Image: ...
142
144
  @staticmethod
143
145
  async def from_id(image_id: str, client: typing.Optional[modal.client._Client] = None) -> _Image: ...
@@ -216,7 +218,7 @@ class _Image(modal._object._Object):
216
218
  context_mount: typing.Optional[modal.mount._Mount] = None,
217
219
  force_build: bool = False,
218
220
  ignore: typing.Union[
219
- collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]
221
+ collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]
220
222
  ] = modal.image.AUTO_DOCKERIGNORE,
221
223
  ) -> _Image: ...
222
224
  def entrypoint(self, entrypoint_commands: list[str]) -> _Image: ...
@@ -304,7 +306,7 @@ class _Image(modal._object._Object):
304
306
  gpu: typing.Union[None, bool, str, modal.gpu._GPUConfig] = None,
305
307
  add_python: typing.Optional[str] = None,
306
308
  ignore: typing.Union[
307
- collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]
309
+ collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]
308
310
  ] = modal.image.AUTO_DOCKERIGNORE,
309
311
  ) -> _Image: ...
310
312
  @staticmethod
@@ -318,7 +320,7 @@ class _Image(modal._object._Object):
318
320
  ) -> _Image: ...
319
321
  def run_function(
320
322
  self,
321
- raw_f: typing.Callable[..., typing.Any],
323
+ raw_f: collections.abc.Callable[..., typing.Any],
322
324
  secrets: collections.abc.Sequence[modal.secret._Secret] = (),
323
325
  gpu: typing.Union[
324
326
  None, bool, str, modal.gpu._GPUConfig, list[typing.Union[None, bool, str, modal.gpu._GPUConfig]]
@@ -345,6 +347,8 @@ class _Image(modal._object._Object):
345
347
  def imports(self): ...
346
348
  def _logs(self) -> typing.AsyncGenerator[str, None]: ...
347
349
 
350
+ SUPERSELF = typing.TypeVar("SUPERSELF", covariant=True)
351
+
348
352
  class Image(modal.object.Object):
349
353
  force_build: bool
350
354
  inside_exceptions: list[Exception]
@@ -365,14 +369,16 @@ class Image(modal.object.Object):
365
369
  *,
366
370
  base_images: typing.Optional[dict[str, Image]] = None,
367
371
  dockerfile_function: typing.Optional[
368
- typing.Callable[[typing.Literal["2023.12", "2024.04", "2024.10"]], DockerfileSpec]
372
+ collections.abc.Callable[[typing.Literal["2023.12", "2024.04", "2024.10"]], DockerfileSpec]
369
373
  ] = None,
370
374
  secrets: typing.Optional[collections.abc.Sequence[modal.secret.Secret]] = None,
371
375
  gpu_config: typing.Optional[modal_proto.api_pb2.GPUConfig] = None,
372
376
  build_function: typing.Optional[modal.functions.Function] = None,
373
377
  build_function_input: typing.Optional[modal_proto.api_pb2.FunctionInput] = None,
374
378
  image_registry_config: typing.Optional[_ImageRegistryConfig] = None,
375
- context_mount_function: typing.Optional[typing.Callable[[], typing.Optional[modal.mount.Mount]]] = None,
379
+ context_mount_function: typing.Optional[
380
+ collections.abc.Callable[[], typing.Optional[modal.mount.Mount]]
381
+ ] = None,
376
382
  force_build: bool = False,
377
383
  _namespace: int = 1,
378
384
  _do_assert_no_mount_layers: bool = True,
@@ -387,7 +393,7 @@ class Image(modal.object.Object):
387
393
  remote_path: str,
388
394
  *,
389
395
  copy: bool = False,
390
- ignore: typing.Union[collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]] = [],
396
+ ignore: typing.Union[collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]] = [],
391
397
  ) -> Image: ...
392
398
  def copy_local_file(
393
399
  self, local_path: typing.Union[str, pathlib.Path], remote_path: typing.Union[str, pathlib.Path] = "./"
@@ -397,14 +403,14 @@ class Image(modal.object.Object):
397
403
  *module_names: str,
398
404
  copy: bool = False,
399
405
  ignore: typing.Union[
400
- collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]
406
+ collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]
401
407
  ] = modal.file_pattern_matcher.NON_PYTHON_FILES,
402
408
  ) -> Image: ...
403
409
  def copy_local_dir(
404
410
  self,
405
411
  local_path: typing.Union[str, pathlib.Path],
406
412
  remote_path: typing.Union[str, pathlib.Path] = ".",
407
- ignore: typing.Union[collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]] = [],
413
+ ignore: typing.Union[collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]] = [],
408
414
  ) -> Image: ...
409
415
 
410
416
  class __from_id_spec(typing_extensions.Protocol):
@@ -488,7 +494,7 @@ class Image(modal.object.Object):
488
494
  context_mount: typing.Optional[modal.mount.Mount] = None,
489
495
  force_build: bool = False,
490
496
  ignore: typing.Union[
491
- collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]
497
+ collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]
492
498
  ] = modal.image.AUTO_DOCKERIGNORE,
493
499
  ) -> Image: ...
494
500
  def entrypoint(self, entrypoint_commands: list[str]) -> Image: ...
@@ -576,7 +582,7 @@ class Image(modal.object.Object):
576
582
  gpu: typing.Union[None, bool, str, modal.gpu._GPUConfig] = None,
577
583
  add_python: typing.Optional[str] = None,
578
584
  ignore: typing.Union[
579
- collections.abc.Sequence[str], typing.Callable[[pathlib.Path], bool]
585
+ collections.abc.Sequence[str], collections.abc.Callable[[pathlib.Path], bool]
580
586
  ] = modal.image.AUTO_DOCKERIGNORE,
581
587
  ) -> Image: ...
582
588
  @staticmethod
@@ -590,7 +596,7 @@ class Image(modal.object.Object):
590
596
  ) -> Image: ...
591
597
  def run_function(
592
598
  self,
593
- raw_f: typing.Callable[..., typing.Any],
599
+ raw_f: collections.abc.Callable[..., typing.Any],
594
600
  secrets: collections.abc.Sequence[modal.secret.Secret] = (),
595
601
  gpu: typing.Union[
596
602
  None, bool, str, modal.gpu._GPUConfig, list[typing.Union[None, bool, str, modal.gpu._GPUConfig]]
@@ -616,10 +622,10 @@ class Image(modal.object.Object):
616
622
  def workdir(self, path: typing.Union[str, pathlib.PurePosixPath]) -> Image: ...
617
623
  def imports(self): ...
618
624
 
619
- class ___logs_spec(typing_extensions.Protocol):
625
+ class ___logs_spec(typing_extensions.Protocol[SUPERSELF]):
620
626
  def __call__(self) -> typing.Generator[str, None, None]: ...
621
627
  def aio(self) -> typing.AsyncGenerator[str, None]: ...
622
628
 
623
- _logs: ___logs_spec
629
+ _logs: ___logs_spec[typing_extensions.Self]
624
630
 
625
631
  SUPPORTED_PYTHON_SERIES: dict[typing.Literal["2023.12", "2024.04", "2024.10"], list[str]]
modal/io_streams.pyi CHANGED
@@ -50,6 +50,8 @@ class _StreamWriter:
50
50
 
51
51
  T_INNER = typing.TypeVar("T_INNER", covariant=True)
52
52
 
53
+ SUPERSELF = typing.TypeVar("SUPERSELF", covariant=True)
54
+
53
55
  class StreamReader(typing.Generic[T]):
54
56
  _stream: typing.Optional[collections.abc.AsyncGenerator[typing.Optional[bytes], None]]
55
57
 
@@ -66,25 +68,25 @@ class StreamReader(typing.Generic[T]):
66
68
  @property
67
69
  def file_descriptor(self) -> int: ...
68
70
 
69
- class __read_spec(typing_extensions.Protocol[T_INNER]):
71
+ class __read_spec(typing_extensions.Protocol[T_INNER, SUPERSELF]):
70
72
  def __call__(self) -> T_INNER: ...
71
73
  async def aio(self) -> T_INNER: ...
72
74
 
73
- read: __read_spec[T]
75
+ read: __read_spec[T, typing_extensions.Self]
74
76
 
75
- class ___consume_container_process_stream_spec(typing_extensions.Protocol):
77
+ class ___consume_container_process_stream_spec(typing_extensions.Protocol[SUPERSELF]):
76
78
  def __call__(self): ...
77
79
  async def aio(self): ...
78
80
 
79
- _consume_container_process_stream: ___consume_container_process_stream_spec
81
+ _consume_container_process_stream: ___consume_container_process_stream_spec[typing_extensions.Self]
80
82
 
81
- class ___stream_container_process_spec(typing_extensions.Protocol):
83
+ class ___stream_container_process_spec(typing_extensions.Protocol[SUPERSELF]):
82
84
  def __call__(self) -> typing.Generator[tuple[typing.Optional[bytes], str], None, None]: ...
83
85
  def aio(self) -> collections.abc.AsyncGenerator[tuple[typing.Optional[bytes], str], None]: ...
84
86
 
85
- _stream_container_process: ___stream_container_process_spec
87
+ _stream_container_process: ___stream_container_process_spec[typing_extensions.Self]
86
88
 
87
- class ___get_logs_spec(typing_extensions.Protocol):
89
+ class ___get_logs_spec(typing_extensions.Protocol[SUPERSELF]):
88
90
  def __call__(
89
91
  self, skip_empty_messages: bool = True
90
92
  ) -> typing.Generator[typing.Optional[bytes], None, None]: ...
@@ -92,13 +94,13 @@ class StreamReader(typing.Generic[T]):
92
94
  self, skip_empty_messages: bool = True
93
95
  ) -> collections.abc.AsyncGenerator[typing.Optional[bytes], None]: ...
94
96
 
95
- _get_logs: ___get_logs_spec
97
+ _get_logs: ___get_logs_spec[typing_extensions.Self]
96
98
 
97
- class ___get_logs_by_line_spec(typing_extensions.Protocol):
99
+ class ___get_logs_by_line_spec(typing_extensions.Protocol[SUPERSELF]):
98
100
  def __call__(self) -> typing.Generator[typing.Optional[bytes], None, None]: ...
99
101
  def aio(self) -> collections.abc.AsyncGenerator[typing.Optional[bytes], None]: ...
100
102
 
101
- _get_logs_by_line: ___get_logs_by_line_spec
103
+ _get_logs_by_line: ___get_logs_by_line_spec[typing_extensions.Self]
102
104
 
103
105
  def __iter__(self) -> typing.Iterator[T]: ...
104
106
  def __aiter__(self) -> collections.abc.AsyncIterator[T]: ...
@@ -115,8 +117,8 @@ class StreamWriter:
115
117
  def write(self, data: typing.Union[bytes, bytearray, memoryview, str]) -> None: ...
116
118
  def write_eof(self) -> None: ...
117
119
 
118
- class __drain_spec(typing_extensions.Protocol):
120
+ class __drain_spec(typing_extensions.Protocol[SUPERSELF]):
119
121
  def __call__(self) -> None: ...
120
122
  async def aio(self) -> None: ...
121
123
 
122
- drain: __drain_spec
124
+ drain: __drain_spec[typing_extensions.Self]