Skip to content

Commit 85758f5

Browse files
committed
rm duplicate of ListPage class
1 parent 9d65884 commit 85758f5

15 files changed

+17
-49
lines changed

src/apify_client/_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ class ListPage(Generic[T]):
2424
"""The limit on the number of returned objects offset specified in the API call."""
2525

2626
limit: int
27-
"""The offset of the first object specified in the API call"""
27+
"""The offset of the first object specified in the API call."""
2828

2929
total: int
3030
"""Total number of objects matching the API call criteria."""
3131

3232
desc: bool
3333
"""Whether the listing is descending or not."""
3434

35-
def __init__(self: ListPage, data: dict) -> None:
35+
def __init__(self, data: dict) -> None:
3636
"""Initialize a ListPage instance from the API response data."""
3737
self.items = data.get('items', [])
3838
self.offset = data.get('offset', 0)

src/apify_client/clients/base/resource_collection_client.py

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,11 @@
11
from __future__ import annotations
22

3-
from typing import Any, Generic, TypeVar
3+
from typing import Any
44

5+
from apify_client._types import ListPage
56
from apify_client._utils import pluck_data
67
from apify_client.clients.base.base_client import BaseClient, BaseClientAsync
78

8-
T = TypeVar('T')
9-
10-
11-
class ListPage(Generic[T]):
12-
"""A single page of items returned from a list() method."""
13-
14-
items: list[T]
15-
"""List of returned objects on this page"""
16-
17-
count: int
18-
"""Count of the returned objects on this page"""
19-
20-
offset: int
21-
"""The limit on the number of returned objects offset specified in the API call"""
22-
23-
limit: int
24-
"""The offset of the first object specified in the API call"""
25-
26-
total: int
27-
"""Total number of objects matching the API call criteria"""
28-
29-
desc: bool
30-
"""Whether the listing is descending or not"""
31-
32-
def __init__(self, data: dict) -> None:
33-
"""Initialize a ListPage instance from the API response data."""
34-
self.items = data.get('items', [])
35-
self.offset = data.get('offset', 0)
36-
self.limit = data.get('limit', 0)
37-
self.count = data['count'] if 'count' in data else len(self.items)
38-
self.total = data['total'] if 'total' in data else self.offset + self.count
39-
self.desc = data.get('desc', False)
40-
419

4210
class ResourceCollectionClient(BaseClient):
4311
"""Base class for sub-clients manipulating a resource collection."""

src/apify_client/clients/resource_clients/actor_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from apify_client.clients.resource_clients.actor import get_actor_representation
99

1010
if TYPE_CHECKING:
11-
from apify_client.clients.base.resource_collection_client import ListPage
11+
from apify_client._types import ListPage
1212

1313

1414
class ActorCollectionClient(ResourceCollectionClient):

src/apify_client/clients/resource_clients/actor_env_var_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from apify_client.clients.resource_clients.actor_env_var import get_actor_env_var_representation
99

1010
if TYPE_CHECKING:
11-
from apify_client.clients.base.resource_collection_client import ListPage
11+
from apify_client._types import ListPage
1212

1313

1414
class ActorEnvVarCollectionClient(ResourceCollectionClient):

src/apify_client/clients/resource_clients/actor_version_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
if TYPE_CHECKING:
1111
from apify_shared.consts import ActorSourceType
1212

13-
from apify_client.clients.base.resource_collection_client import ListPage
13+
from apify_client._types import ListPage
1414

1515

1616
class ActorVersionCollectionClient(ResourceCollectionClient):

src/apify_client/clients/resource_clients/build_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
if TYPE_CHECKING:
88
from apify_client._models import BuildShort
9-
from apify_client.clients.base.resource_collection_client import ListPage
9+
from apify_client._types import ListPage
1010

1111

1212
class BuildCollectionClient(ResourceCollectionClient):

src/apify_client/clients/resource_clients/dataset_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from apify_client.clients.base import ResourceCollectionClient, ResourceCollectionClientAsync
88

99
if TYPE_CHECKING:
10-
from apify_client.clients.base.resource_collection_client import ListPage
10+
from apify_client._types import ListPage
1111

1212

1313
class DatasetCollectionClient(ResourceCollectionClient):

src/apify_client/clients/resource_clients/key_value_store_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from apify_client.clients.base import ResourceCollectionClient, ResourceCollectionClientAsync
88

99
if TYPE_CHECKING:
10-
from apify_client.clients.base.resource_collection_client import ListPage
10+
from apify_client._types import ListPage
1111

1212

1313
class KeyValueStoreCollectionClient(ResourceCollectionClient):

src/apify_client/clients/resource_clients/request_queue_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from apify_client.clients.base import ResourceCollectionClient, ResourceCollectionClientAsync
77

88
if TYPE_CHECKING:
9-
from apify_client.clients.base.resource_collection_client import ListPage
9+
from apify_client._types import ListPage
1010

1111

1212
class RequestQueueCollectionClient(ResourceCollectionClient):

src/apify_client/clients/resource_clients/run_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from apify_shared.consts import ActorJobStatus
1212

1313
from apify_client._models import RunShort
14-
from apify_client.clients.base.resource_collection_client import ListPage
14+
from apify_client._types import ListPage
1515

1616

1717
class RunCollectionClient(ResourceCollectionClient):

0 commit comments

Comments
 (0)