apify 2.2.0b14__py3-none-any.whl → 2.2.1b1__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.

Potentially problematic release.


This version of apify might be problematic. Click here for more details.

apify/__init__.py CHANGED
@@ -2,7 +2,15 @@ from importlib import metadata
2
2
 
3
3
  from apify_shared.consts import WebhookEventType
4
4
  from crawlee import Request
5
- from crawlee.events._types import Event
5
+ from crawlee.events import (
6
+ Event,
7
+ EventAbortingData,
8
+ EventExitData,
9
+ EventListener,
10
+ EventMigratingData,
11
+ EventPersistStateData,
12
+ EventSystemInfoData,
13
+ )
6
14
 
7
15
  from apify._actor import Actor
8
16
  from apify._configuration import Configuration
@@ -15,6 +23,12 @@ __all__ = [
15
23
  'Actor',
16
24
  'Configuration',
17
25
  'Event',
26
+ 'EventAbortingData',
27
+ 'EventExitData',
28
+ 'EventListener',
29
+ 'EventMigratingData',
30
+ 'EventPersistStateData',
31
+ 'EventSystemInfoData',
18
32
  'ProxyConfiguration',
19
33
  'ProxyInfo',
20
34
  'Request',
apify/_actor.py CHANGED
@@ -4,7 +4,7 @@ import asyncio
4
4
  import os
5
5
  import sys
6
6
  from datetime import timedelta
7
- from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast
7
+ from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar, cast, overload
8
8
 
9
9
  from lazy_object_proxy import Proxy
10
10
  from more_itertools import flatten
@@ -14,7 +14,15 @@ from apify_client import ApifyClientAsync
14
14
  from apify_shared.consts import ActorEnvVars, ActorExitCodes, ApifyEnvVars
15
15
  from apify_shared.utils import ignore_docs, maybe_extract_enum_member_value
16
16
  from crawlee import service_locator
17
- from crawlee.events._types import Event, EventMigratingData, EventPersistStateData
17
+ from crawlee.events import (
18
+ Event,
19
+ EventAbortingData,
20
+ EventExitData,
21
+ EventListener,
22
+ EventMigratingData,
23
+ EventPersistStateData,
24
+ EventSystemInfoData,
25
+ )
18
26
 
19
27
  from apify._configuration import Configuration
20
28
  from apify._consts import EVENT_LISTENERS_TIMEOUT
@@ -498,7 +506,30 @@ class _ActorType:
498
506
  key_value_store = await self.open_key_value_store()
499
507
  return await key_value_store.set_value(key, value, content_type=content_type)
500
508
 
501
- def on(self, event_name: Event, listener: Callable) -> Callable:
509
+ @overload
510
+ def on(
511
+ self, event_name: Literal[Event.PERSIST_STATE], listener: EventListener[EventPersistStateData]
512
+ ) -> EventListener[EventPersistStateData]: ...
513
+ @overload
514
+ def on(
515
+ self, event_name: Literal[Event.SYSTEM_INFO], listener: EventListener[EventSystemInfoData]
516
+ ) -> EventListener[EventSystemInfoData]: ...
517
+ @overload
518
+ def on(
519
+ self, event_name: Literal[Event.MIGRATING], listener: EventListener[EventMigratingData]
520
+ ) -> EventListener[EventMigratingData]: ...
521
+ @overload
522
+ def on(
523
+ self, event_name: Literal[Event.ABORTING], listener: EventListener[EventAbortingData]
524
+ ) -> EventListener[EventAbortingData]: ...
525
+ @overload
526
+ def on(
527
+ self, event_name: Literal[Event.EXIT], listener: EventListener[EventExitData]
528
+ ) -> EventListener[EventExitData]: ...
529
+ @overload
530
+ def on(self, event_name: Event, listener: EventListener[None]) -> EventListener[Any]: ...
531
+
532
+ def on(self, event_name: Event, listener: EventListener[Any]) -> EventListener[Any]:
502
533
  """Add an event listener to the Actor's event manager.
503
534
 
504
535
  The following events can be emitted:
@@ -527,6 +558,19 @@ class _ActorType:
527
558
  self._event_manager.on(event=event_name, listener=listener)
528
559
  return listener
529
560
 
561
+ @overload
562
+ def off(self, event_name: Literal[Event.PERSIST_STATE], listener: EventListener[EventPersistStateData]) -> None: ...
563
+ @overload
564
+ def off(self, event_name: Literal[Event.SYSTEM_INFO], listener: EventListener[EventSystemInfoData]) -> None: ...
565
+ @overload
566
+ def off(self, event_name: Literal[Event.MIGRATING], listener: EventListener[EventMigratingData]) -> None: ...
567
+ @overload
568
+ def off(self, event_name: Literal[Event.ABORTING], listener: EventListener[EventAbortingData]) -> None: ...
569
+ @overload
570
+ def off(self, event_name: Literal[Event.EXIT], listener: EventListener[EventExitData]) -> None: ...
571
+ @overload
572
+ def off(self, event_name: Event, listener: EventListener[None]) -> None: ...
573
+
530
574
  def off(self, event_name: Event, listener: Callable | None = None) -> None:
531
575
  """Remove a listener, or all listeners, from an Actor event.
532
576
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: apify
3
- Version: 2.2.0b14
3
+ Version: 2.2.1b1
4
4
  Summary: Apify SDK for Python
5
5
  License: Apache-2.0
6
6
  Keywords: apify,sdk,automation,chrome,crawlee,crawler,headless,scraper,scraping
@@ -1,5 +1,5 @@
1
- apify/__init__.py,sha256=99ynaDWBLEcCjdLq7R0Exy_iACsXiXoQ8VUZKmbzTeM,550
2
- apify/_actor.py,sha256=X8UCTYVJmsq0Nus7aru1ayEgrbo8QE__0jKaN8aWMZ0,44313
1
+ apify/__init__.py,sha256=HpgKg2FZWJuSPfDygzJ62psylhw4NN4tKFnoYUIhcd4,838
2
+ apify/_actor.py,sha256=e9DeE9vqKzPyiyDO-yRufpqvjAn2sV0KldElWmSTy0I,46137
3
3
  apify/_configuration.py,sha256=T3Z_o_W98iSyTbrutfb578yW51aexZ_V0FcLwTxFLjI,10878
4
4
  apify/_consts.py,sha256=_Xq4hOfOA1iZ3n1P967YWdyncKivpbX6RTlp_qanUoE,330
5
5
  apify/_crypto.py,sha256=e0_aM3l9_5Osk-jszYOOjrAKK60OggSHbiw5c30QnsU,5638
@@ -32,7 +32,7 @@ apify/scrapy/utils.py,sha256=758DcHCSAgCTProY0QX74uJ1XrzVsQwvCmFanj2f_3Q,2928
32
32
  apify/storages/__init__.py,sha256=FW-z6ubuPnHGM-Wp15T8mR5q6lnpDGrCW-IkgZd5L30,177
33
33
  apify/storages/_request_list.py,sha256=-lZJcE5nq69aJhGFJ7Sh2ctqgAWUDyOwYm5_0y1hdAE,5865
34
34
  apify/storages/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- apify-2.2.0b14.dist-info/LICENSE,sha256=AsFjHssKjj4LGd2ZCqXn6FBzMqcWdjQre1byPPSypVw,11355
36
- apify-2.2.0b14.dist-info/METADATA,sha256=vagvl8FfixTKDEiYx3WI7D541NifN21SGjWuFVCuOHE,8714
37
- apify-2.2.0b14.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
38
- apify-2.2.0b14.dist-info/RECORD,,
35
+ apify-2.2.1b1.dist-info/LICENSE,sha256=AsFjHssKjj4LGd2ZCqXn6FBzMqcWdjQre1byPPSypVw,11355
36
+ apify-2.2.1b1.dist-info/METADATA,sha256=f5wyK4TgVDod-EHYXMy0Dg30LZnnKDDpsI3OXQ2F2Jk,8713
37
+ apify-2.2.1b1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
38
+ apify-2.2.1b1.dist-info/RECORD,,