Skip to content

Commit 7dc2627

Browse files
vdusekclaude
andcommitted
refactor: Replace kwargs.pop with explicit resource_path keyword arguments
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0f647ed commit 7dc2627

22 files changed

+464
-138
lines changed

src/apify_client/_resource_clients/actor_collection.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ class ActorCollectionClient(ResourceClient):
2020
method on the `ApifyClient` class.
2121
"""
2222

23-
def __init__(self, *args: Any, **kwargs: Any) -> None:
24-
resource_path = kwargs.pop('resource_path', 'acts')
25-
super().__init__(*args, resource_path=resource_path, **kwargs)
23+
def __init__(
24+
self,
25+
*,
26+
resource_path: str = 'acts',
27+
**kwargs: Any,
28+
) -> None:
29+
super().__init__(
30+
resource_path=resource_path,
31+
**kwargs,
32+
)
2633

2734
def list(
2835
self,
@@ -152,9 +159,16 @@ class ActorCollectionClientAsync(ResourceClientAsync):
152159
method on the `ApifyClientAsync` class.
153160
"""
154161

155-
def __init__(self, *args: Any, **kwargs: Any) -> None:
156-
resource_path = kwargs.pop('resource_path', 'acts')
157-
super().__init__(*args, resource_path=resource_path, **kwargs)
162+
def __init__(
163+
self,
164+
*,
165+
resource_path: str = 'acts',
166+
**kwargs: Any,
167+
) -> None:
168+
super().__init__(
169+
resource_path=resource_path,
170+
**kwargs,
171+
)
158172

159173
async def list(
160174
self,

src/apify_client/_resource_clients/actor_env_var.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@ class ActorEnvVarClient(ResourceClient):
3030
via an appropriate method on the `ActorVersionClient` class.
3131
"""
3232

33-
def __init__(self, *args: Any, **kwargs: Any) -> None:
34-
resource_path = kwargs.pop('resource_path', 'env-vars')
35-
super().__init__(*args, resource_path=resource_path, **kwargs)
33+
def __init__(
34+
self,
35+
*,
36+
resource_id: str,
37+
resource_path: str = 'env-vars',
38+
**kwargs: Any,
39+
) -> None:
40+
super().__init__(
41+
resource_id=resource_id,
42+
resource_path=resource_path,
43+
**kwargs,
44+
)
3645

3746
def get(self) -> EnvVar | None:
3847
"""Return information about the Actor environment variable.
@@ -91,9 +100,18 @@ class ActorEnvVarClientAsync(ResourceClientAsync):
91100
via an appropriate method on the `ActorVersionClientAsync` class.
92101
"""
93102

94-
def __init__(self, *args: Any, **kwargs: Any) -> None:
95-
resource_path = kwargs.pop('resource_path', 'env-vars')
96-
super().__init__(*args, resource_path=resource_path, **kwargs)
103+
def __init__(
104+
self,
105+
*,
106+
resource_id: str,
107+
resource_path: str = 'env-vars',
108+
**kwargs: Any,
109+
) -> None:
110+
super().__init__(
111+
resource_id=resource_id,
112+
resource_path=resource_path,
113+
**kwargs,
114+
)
97115

98116
async def get(self) -> EnvVar | None:
99117
"""Return information about the Actor environment variable.

src/apify_client/_resource_clients/actor_env_var_collection.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@ class ActorEnvVarCollectionClient(ResourceClient):
1717
appropriate method on the `ActorVersionClient` class.
1818
"""
1919

20-
def __init__(self, *args: Any, **kwargs: Any) -> None:
21-
resource_path = kwargs.pop('resource_path', 'env-vars')
22-
super().__init__(*args, resource_path=resource_path, **kwargs)
20+
def __init__(
21+
self,
22+
*,
23+
resource_path: str = 'env-vars',
24+
**kwargs: Any,
25+
) -> None:
26+
super().__init__(
27+
resource_path=resource_path,
28+
**kwargs,
29+
)
2330

2431
def list(self) -> ListOfEnvVars:
2532
"""List the available Actor environment variables.
@@ -69,9 +76,16 @@ class ActorEnvVarCollectionClientAsync(ResourceClientAsync):
6976
appropriate method on the `ActorVersionClientAsync` class.
7077
"""
7178

72-
def __init__(self, *args: Any, **kwargs: Any) -> None:
73-
resource_path = kwargs.pop('resource_path', 'env-vars')
74-
super().__init__(*args, resource_path=resource_path, **kwargs)
79+
def __init__(
80+
self,
81+
*,
82+
resource_path: str = 'env-vars',
83+
**kwargs: Any,
84+
) -> None:
85+
super().__init__(
86+
resource_path=resource_path,
87+
**kwargs,
88+
)
7589

7690
async def list(self) -> ListOfEnvVars:
7791
"""List the available Actor environment variables.

src/apify_client/_resource_clients/actor_version_collection.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@ class ActorVersionCollectionClient(ResourceClient):
2323
on the `ActorClient` class.
2424
"""
2525

26-
def __init__(self, *args: Any, **kwargs: Any) -> None:
27-
resource_path = kwargs.pop('resource_path', 'versions')
28-
super().__init__(*args, resource_path=resource_path, **kwargs)
26+
def __init__(
27+
self,
28+
*,
29+
resource_path: str = 'versions',
30+
**kwargs: Any,
31+
) -> None:
32+
super().__init__(
33+
resource_path=resource_path,
34+
**kwargs,
35+
)
2936

3037
def list(self) -> ListOfVersions:
3138
"""List the available Actor versions.
@@ -99,9 +106,16 @@ class ActorVersionCollectionClientAsync(ResourceClientAsync):
99106
on the `ActorClientAsync` class.
100107
"""
101108

102-
def __init__(self, *args: Any, **kwargs: Any) -> None:
103-
resource_path = kwargs.pop('resource_path', 'versions')
104-
super().__init__(*args, resource_path=resource_path, **kwargs)
109+
def __init__(
110+
self,
111+
*,
112+
resource_path: str = 'versions',
113+
**kwargs: Any,
114+
) -> None:
115+
super().__init__(
116+
resource_path=resource_path,
117+
**kwargs,
118+
)
105119

106120
async def list(self) -> ListOfVersions:
107121
"""List the available Actor versions.

src/apify_client/_resource_clients/build_collection.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@ class BuildCollectionClient(ResourceClient):
1515
`ApifyClient` class.
1616
"""
1717

18-
def __init__(self, *args: Any, **kwargs: Any) -> None:
19-
resource_path = kwargs.pop('resource_path', 'actor-builds')
20-
super().__init__(*args, resource_path=resource_path, **kwargs)
18+
def __init__(
19+
self,
20+
*,
21+
resource_path: str = 'actor-builds',
22+
**kwargs: Any,
23+
) -> None:
24+
super().__init__(
25+
resource_path=resource_path,
26+
**kwargs,
27+
)
2128

2229
def list(
2330
self,
@@ -54,9 +61,16 @@ class BuildCollectionClientAsync(ResourceClientAsync):
5461
`ApifyClientAsync` class.
5562
"""
5663

57-
def __init__(self, *args: Any, **kwargs: Any) -> None:
58-
resource_path = kwargs.pop('resource_path', 'actor-builds')
59-
super().__init__(*args, resource_path=resource_path, **kwargs)
64+
def __init__(
65+
self,
66+
*,
67+
resource_path: str = 'actor-builds',
68+
**kwargs: Any,
69+
) -> None:
70+
super().__init__(
71+
resource_path=resource_path,
72+
**kwargs,
73+
)
6074

6175
async def list(
6276
self,

src/apify_client/_resource_clients/dataset.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,18 @@ class DatasetClient(ResourceClient):
6565
via an appropriate method on the `ApifyClient` class.
6666
"""
6767

68-
def __init__(self, *args: Any, **kwargs: Any) -> None:
69-
resource_path = kwargs.pop('resource_path', 'datasets')
70-
super().__init__(*args, resource_path=resource_path, **kwargs)
68+
def __init__(
69+
self,
70+
*,
71+
resource_id: str | None = None,
72+
resource_path: str = 'datasets',
73+
**kwargs: Any,
74+
) -> None:
75+
super().__init__(
76+
resource_id=resource_id,
77+
resource_path=resource_path,
78+
**kwargs,
79+
)
7180

7281
def get(self) -> Dataset | None:
7382
"""Retrieve the dataset.
@@ -686,9 +695,18 @@ class DatasetClientAsync(ResourceClientAsync):
686695
via an appropriate method on the `ApifyClientAsync` class.
687696
"""
688697

689-
def __init__(self, *args: Any, **kwargs: Any) -> None:
690-
resource_path = kwargs.pop('resource_path', 'datasets')
691-
super().__init__(*args, resource_path=resource_path, **kwargs)
698+
def __init__(
699+
self,
700+
*,
701+
resource_id: str | None = None,
702+
resource_path: str = 'datasets',
703+
**kwargs: Any,
704+
) -> None:
705+
super().__init__(
706+
resource_id=resource_id,
707+
resource_path=resource_path,
708+
**kwargs,
709+
)
692710

693711
async def get(self) -> Dataset | None:
694712
"""Retrieve the dataset.

src/apify_client/_resource_clients/dataset_collection.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ class DatasetCollectionClient(ResourceClient):
1616
appropriate method on the `ApifyClient` class.
1717
"""
1818

19-
def __init__(self, *args: Any, **kwargs: Any) -> None:
20-
resource_path = kwargs.pop('resource_path', 'datasets')
21-
super().__init__(*args, resource_path=resource_path, **kwargs)
19+
def __init__(
20+
self,
21+
*,
22+
resource_path: str = 'datasets',
23+
**kwargs: Any,
24+
) -> None:
25+
super().__init__(
26+
resource_path=resource_path,
27+
**kwargs,
28+
)
2229

2330
def list(
2431
self,
@@ -68,9 +75,16 @@ class DatasetCollectionClientAsync(ResourceClientAsync):
6875
appropriate method on the `ApifyClientAsync` class.
6976
"""
7077

71-
def __init__(self, *args: Any, **kwargs: Any) -> None:
72-
resource_path = kwargs.pop('resource_path', 'datasets')
73-
super().__init__(*args, resource_path=resource_path, **kwargs)
78+
def __init__(
79+
self,
80+
*,
81+
resource_path: str = 'datasets',
82+
**kwargs: Any,
83+
) -> None:
84+
super().__init__(
85+
resource_path=resource_path,
86+
**kwargs,
87+
)
7488

7589
async def list(
7690
self,

src/apify_client/_resource_clients/key_value_store.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,18 @@ class KeyValueStoreClient(ResourceClient):
7676
instance via an appropriate method on the `ApifyClient` class.
7777
"""
7878

79-
def __init__(self, *args: Any, **kwargs: Any) -> None:
80-
resource_path = kwargs.pop('resource_path', 'key-value-stores')
81-
super().__init__(*args, resource_path=resource_path, **kwargs)
79+
def __init__(
80+
self,
81+
*,
82+
resource_id: str | None = None,
83+
resource_path: str = 'key-value-stores',
84+
**kwargs: Any,
85+
) -> None:
86+
super().__init__(
87+
resource_id=resource_id,
88+
resource_path=resource_path,
89+
**kwargs,
90+
)
8291

8392
def get(self) -> KeyValueStore | None:
8493
"""Retrieve the key-value store.
@@ -460,9 +469,18 @@ class KeyValueStoreClientAsync(ResourceClientAsync):
460469
instance via an appropriate method on the `ApifyClientAsync` class.
461470
"""
462471

463-
def __init__(self, *args: Any, **kwargs: Any) -> None:
464-
resource_path = kwargs.pop('resource_path', 'key-value-stores')
465-
super().__init__(*args, resource_path=resource_path, **kwargs)
472+
def __init__(
473+
self,
474+
*,
475+
resource_id: str | None = None,
476+
resource_path: str = 'key-value-stores',
477+
**kwargs: Any,
478+
) -> None:
479+
super().__init__(
480+
resource_id=resource_id,
481+
resource_path=resource_path,
482+
**kwargs,
483+
)
466484

467485
async def get(self) -> KeyValueStore | None:
468486
"""Retrieve the key-value store.

src/apify_client/_resource_clients/key_value_store_collection.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@ class KeyValueStoreCollectionClient(ResourceClient):
2121
via an appropriate method on the `ApifyClient` class.
2222
"""
2323

24-
def __init__(self, *args: Any, **kwargs: Any) -> None:
25-
resource_path = kwargs.pop('resource_path', 'key-value-stores')
26-
super().__init__(*args, resource_path=resource_path, **kwargs)
24+
def __init__(
25+
self,
26+
*,
27+
resource_path: str = 'key-value-stores',
28+
**kwargs: Any,
29+
) -> None:
30+
super().__init__(
31+
resource_path=resource_path,
32+
**kwargs,
33+
)
2734

2835
def list(
2936
self,
@@ -78,9 +85,16 @@ class KeyValueStoreCollectionClientAsync(ResourceClientAsync):
7885
via an appropriate method on the `ApifyClientAsync` class.
7986
"""
8087

81-
def __init__(self, *args: Any, **kwargs: Any) -> None:
82-
resource_path = kwargs.pop('resource_path', 'key-value-stores')
83-
super().__init__(*args, resource_path=resource_path, **kwargs)
88+
def __init__(
89+
self,
90+
*,
91+
resource_path: str = 'key-value-stores',
92+
**kwargs: Any,
93+
) -> None:
94+
super().__init__(
95+
resource_path=resource_path,
96+
**kwargs,
97+
)
8498

8599
async def list(
86100
self,

0 commit comments

Comments
 (0)