Skip to content

Commit 98f4e85

Browse files
committed
Improve return types
1 parent 7c09b49 commit 98f4e85

File tree

9 files changed

+49
-49
lines changed

9 files changed

+49
-49
lines changed

scrapinghub/client/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def get_project(self, project_id):
5858
5959
:param project_id: integer or string numeric project id.
6060
:return: :class:`Project` object.
61-
:rtype: scrapinghub.client.projects.Project
61+
:rtype: :class:`scrapinghub.client.projects.Project`
6262
6363
Usage::
6464
@@ -74,7 +74,7 @@ def get_job(self, job_key):
7474
:param job_key: job key string in format 'project_id/spider_id/job_id',
7575
where all the components are integers.
7676
:return: :class:`Job` object.
77-
:rtype: scrapinghub.client.jobs.Job
77+
:rtype: :class:`scrapinghub.client.jobs.Job`
7878
7979
Usage::
8080

scrapinghub/client/collections.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def get(self, type_, name):
3030
:param type_: a collection type string.
3131
:param name: a collection name string.
3232
:return: :class:`Collection` object.
33-
:rtype: Collection
33+
:rtype: :class:`Collection`
3434
"""
3535
self._origin._validate_collection(type_, name)
3636
return Collection(self._client, self, type_, name)
@@ -40,7 +40,7 @@ def get_store(self, name):
4040
4141
:param name: a collection name string.
4242
:return: :class:`Collection` object.
43-
:rtype: Collection
43+
:rtype: :class:`Collection`
4444
"""
4545
return self.get('s', name)
4646

@@ -51,7 +51,7 @@ def get_cached_store(self, name):
5151
5252
:param name: a collection name string.
5353
:return: :class:`Collection` object.
54-
:rtype: Collection
54+
:rtype: :class:`Collection`
5555
"""
5656
return self.get('cs', name)
5757

@@ -62,7 +62,7 @@ def get_versioned_store(self, name):
6262
6363
:param name: a collection name string.
6464
:return: :class:`Collection` object.
65-
:rtype: Collection
65+
:rtype: :class:`Collection`
6666
"""
6767
return self.get('vs', name)
6868

@@ -73,7 +73,7 @@ def get_versioned_cached_store(self, name):
7373
7474
:param name: a collection name string.
7575
:return: :class:`Collection` object.
76-
:rtype: Collection
76+
:rtype: :class:`Collection`
7777
"""
7878
return self.get('vcs', name)
7979

@@ -82,7 +82,7 @@ def iter(self):
8282
8383
:return: an iterator over collections list where each collection is
8484
represented by a dictionary with ('name','type') fields.
85-
:rtype: collections.Iterable[dict]
85+
:rtype: :class:`collections.Iterable[dict]`
8686
"""
8787
return self._origin.apiget('list')
8888

@@ -91,7 +91,7 @@ def list(self):
9191
9292
:return: a list of collections where each collection is
9393
represented by a dictionary with ('name','type') fields.
94-
:rtype: List[dict]
94+
:rtype: :class:`list[dict]`
9595
"""
9696
return list(self.iter())
9797

@@ -171,7 +171,7 @@ def list(self, key=None, prefix=None, prefixcount=None, startts=None,
171171
:param requests_params: (optional) a dict with optional requests params.
172172
:param \*\*params: (optional) additional query params for the request.
173173
:return: a list of items where each item is represented with a dict.
174-
:rtype: List[dict]
174+
:rtype: :class:`list[dict]`
175175
"""
176176
# FIXME there should be similar docstrings for iter/iter_raw_json
177177
# but as we proxy them as-is, it's not in place, should be improved
@@ -186,7 +186,7 @@ def get(self, key, **params):
186186
:param key: string item key.
187187
:param \*\*params: (optional) additional query params for the request.
188188
:return: an item dictionary if exists.
189-
:rtype: dict
189+
:rtype: :class:`dict`
190190
"""
191191
if key is None:
192192
raise ValueError("key cannot be None")
@@ -228,7 +228,7 @@ def iter_raw_msgpack(self, key=None, prefix=None, prefixcount=None,
228228
:param requests_params: (optional) a dict with optional requests params.
229229
:param \*\*params: (optional) additional query params for the request.
230230
:return: an iterator over items list packed with msgpack.
231-
:rtype: collections.Iterable[bytes]
231+
:rtype: :class:`collections.Iterable[bytes]`
232232
"""
233233
update_kwargs(params, key=key, prefix=prefix, prefixcount=prefixcount,
234234
startts=startts, endts=endts,

scrapinghub/client/frontiers.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _get_writer(self, frontier, slot):
2222
callback to write newcount data per slot.
2323
2424
:return: a batchuploader writer instance.
25-
:rtype: scrapinghub.hubstorage.batchuploader._BatchWriter
25+
:rtype: :class:`scrapinghub.hubstorage.batchuploader._BatchWriter`
2626
"""
2727
key = (frontier, slot)
2828
writer = self._writers.get(key)
@@ -89,23 +89,23 @@ def get(self, name):
8989
9090
:param name: a frontier name string.
9191
:return: :class:`Frontier` instance.
92-
:rtype: Frontier
92+
:rtype: :class:`Frontier`
9393
"""
9494
return Frontier(self._client, self, name)
9595

9696
def iter(self):
9797
"""Iterate through frontiers.
9898
9999
:return: an iterator over frontiers names.
100-
:rtype: collections.Iterable[str]
100+
:rtype: :class:`collections.Iterable[str]`
101101
"""
102102
return iter(self.list())
103103

104104
def list(self):
105105
"""List frontiers names.
106106
107107
:return: a list of frontiers names.
108-
:rtype: List[str]
108+
:rtype: :class:`list[str]`
109109
"""
110110
return next(self._origin.apiget('list'))
111111

@@ -155,23 +155,23 @@ def get(self, slot):
155155
"""Get a slot by name.
156156
157157
:return: :class:`FrontierSlot` instance.
158-
:rtype: FrontierSlot
158+
:rtype: :class:`FrontierSlot`
159159
"""
160160
return FrontierSlot(self._client, self, slot)
161161

162162
def iter(self):
163163
"""Iterate through slots.
164164
165165
:return: an iterator over frontier slots names.
166-
:rtype: collections.Iterate[str]
166+
:rtype: :class:`collections.Iterate[str]`
167167
"""
168168
return iter(self.list())
169169

170170
def list(self):
171171
"""List all slots.
172172
173173
:return: a list of frontier slots names.
174-
:rtype: List[str]
174+
:rtype: :class:`list[str]`
175175
"""
176176
return next(self._frontiers._origin.apiget((self.key, 'list')))
177177

@@ -250,7 +250,7 @@ def f(self):
250250
"""Shortcut to have quick access to slot fingerprints.
251251
252252
:return: :class:`FrontierSlotFingerprints` instance.
253-
:rtype: FrontierSlotFingerprints
253+
:rtype: :class:`FrontierSlotFingerprints`
254254
"""
255255
return self.fingerprints
256256

@@ -259,7 +259,7 @@ def q(self):
259259
"""Shortcut to have quick access to a slot queue.
260260
261261
:return: :class:`FrontierSlotQueue` instance.
262-
:rtype: FrontierSlotQueue
262+
:rtype: :class:`FrontierSlotQueue`
263263
"""
264264
return self.queue
265265

@@ -303,7 +303,7 @@ def iter(self, **params):
303303
304304
:param \*\*params: (optional) additional query params for the request.
305305
:return: an iterator over fingerprints.
306-
:rtype: collections.Iterable[str]
306+
:rtype: :class:`collections.Iterable[str]`
307307
"""
308308
origin = self._frontier._frontiers._origin
309309
path = (self._frontier.key, 's', self.key, 'f')
@@ -315,7 +315,7 @@ def list(self, **params):
315315
316316
:param \*\*params: (optional) additional query params for the request.
317317
:return: a list of fingerprints.
318-
:rtype: List[str]
318+
:rtype: :class:`list[str]`
319319
"""
320320
return list(self.iter(**params))
321321

@@ -339,7 +339,7 @@ def iter(self, mincount=None, **params):
339339
:param \*\*params: (optional) additional query params for the request.
340340
:return: an iterator over request batches in the queue where each
341341
batch is represented with a dict with ('id', 'requests') field.
342-
:rtype: collections.Iterable[dict]
342+
:rtype: :class:`collections.Iterable[dict]`
343343
"""
344344
origin = self._frontier._frontiers._origin
345345
path = (self._frontier.key, 's', self.key, 'q')
@@ -353,7 +353,7 @@ def list(self, mincount=None, **params):
353353
:param \*\*params: (optional) additional query params for the request.
354354
:return: a list of request batches in the queue where each batch
355355
is represented with a dict with ('id', 'requests') field.
356-
:rtype: List[dict]
356+
:rtype: :class:`list[dict]`
357357
"""
358358
return list(self.iter(mincount=mincount, **params))
359359

scrapinghub/client/items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def _modify_iter_params(self, params):
5050
"""Modify iter filter to convert offset to start parameter.
5151
5252
:return: a dict with updated set of params.
53-
:rtype: dict
53+
:rtype: :class:`dict`
5454
"""
5555
params = super(Items, self)._modify_iter_params(params)
5656
offset = params.pop('offset', None)

scrapinghub/client/jobs.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def count(self, spider=None, state=None, has_tag=None, lacks_tag=None,
5858
:param \*\*params: (optional) other filter params.
5959
6060
:return: jobs count.
61-
:rtype: int
61+
:rtype: :class:`int`
6262
6363
Usage::
6464
@@ -97,7 +97,7 @@ def iter(self, count=None, start=None, spider=None, state=None,
9797
9898
:return: a generator object over a list of dictionaries of jobs summary
9999
for a given filter params.
100-
:rtype: types.GeneratorType[dict]
100+
:rtype: :class:`types.GeneratorType[dict]`
101101
102102
Usage:
103103
@@ -164,7 +164,7 @@ def list(self, count=None, start=None, spider=None, state=None,
164164
:param \*\*params: (optional) other filter params.
165165
166166
:return: list of dictionaries of jobs summary for a given filter params
167-
:rtype: List[dict]
167+
:rtype: :class:`list[dict]`
168168
169169
Please note that list() method can use a lot of memory and for a large
170170
amount of jobs it's recommended to iterate through it via iter()
@@ -195,7 +195,7 @@ def run(self, spider=None, units=None, priority=None, meta=None,
195195
:param \*\*params: (optional) additional keyword args.
196196
197197
:return: a job key string pointing to the new job.
198-
:rtype: str
198+
:rtype: :class:`str`
199199
200200
Usage::
201201
@@ -236,7 +236,7 @@ def get(self, job_key):
236236
the spider (if :attr:`Spider.jobs` was used).
237237
238238
:return: :class:`Job` object.
239-
:rtype: scrapinghub.client.jobs.Job
239+
:rtype: :class:`Job`
240240
241241
Usage::
242242
@@ -260,7 +260,7 @@ def summary(self, state=None, spider=None, **params):
260260
:param \*\*params: (optional) additional keyword args.
261261
:return: a list of dictionaries of jobs summary
262262
for a given filter params grouped by job state.
263-
:rtype: List[dict]
263+
:rtype: :class:`list[dict]`
264264
265265
Usage::
266266
@@ -288,7 +288,7 @@ def iter_last(self, start=None, start_after=None, count=None,
288288
:param \*\*params: (optional) additional keyword args.
289289
:return: a generator object over a list of dictionaries of jobs summary
290290
for a given filter params.
291-
:rtype: types.GeneratorType[dict]
291+
:rtype: :class:`types.GeneratorType[dict]`
292292
293293
Usage:
294294
@@ -341,7 +341,7 @@ def update_tags(self, add=None, remove=None, spider=None):
341341
have to specify ``spider`` param when using :attr:`Project.jobs`).
342342
343343
:return: amount of jobs that were updated.
344-
:rtype: int
344+
:rtype: :class:`int`
345345
346346
Usage:
347347
@@ -436,7 +436,7 @@ def start(self, **params):
436436
437437
:param \*\*params: (optional) keyword meta parameters to update.
438438
:return: a previous string job state.
439-
:rtype: str
439+
:rtype: :class:`str`
440440
441441
Usage::
442442
@@ -450,7 +450,7 @@ def finish(self, **params):
450450
451451
:param \*\*params: (optional) keyword meta parameters to update.
452452
:return: a previous string job state.
453-
:rtype: str
453+
:rtype: :class:`str`
454454
455455
Usage::
456456
@@ -464,7 +464,7 @@ def delete(self, **params):
464464
465465
:param \*\*params: (optional) keyword meta parameters to update.
466466
:return: a previous string job state.
467-
:rtype: str
467+
:rtype: :class:`str`
468468
469469
Usage::
470470
@@ -479,7 +479,7 @@ def update(self, state, **params):
479479
:param state: a new job state.
480480
:param \*\*params: (optional) keyword meta parameters to update.
481481
:return: a previous string job state.
482-
:rtype: str
482+
:rtype: :class:`str`
483483
484484
Usage::
485485

scrapinghub/client/logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _modify_iter_params(self, params):
6060
6161
:param params: an original dictionary with params.
6262
:return: a modified dictionary with params.
63-
:rtype: dict
63+
:rtype: :class:`dict`
6464
"""
6565
params = super(Logs, self)._modify_iter_params(params)
6666
offset = params.pop('offset', None)

scrapinghub/client/projects.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def get(self, project_id):
3232
3333
:param project_id: integer or string numeric project id.
3434
:return: :class:`Project` object.
35-
:rtype: scrapinghub.client.projects.Project
35+
:rtype: :class:`scrapinghub.client.projects.Project`
3636
3737
Usage::
3838
@@ -46,7 +46,7 @@ def list(self):
4646
"""Get list of projects available to current user.
4747
4848
:return: a list of project ids.
49-
:rtype: List[int]
49+
:rtype: :class:`list[int]`
5050
5151
Usage::
5252
@@ -61,7 +61,7 @@ def iter(self):
6161
Provided for the sake of API consistency.
6262
6363
:return: an iterator over project ids list.
64-
:rtype: collections.Iterable[int]
64+
:rtype: :class:`collections.Iterable[int]`
6565
"""
6666
return iter(self.list())
6767

@@ -72,7 +72,7 @@ def summary(self, state=None, **params):
7272
:return: a list of dictionaries: each dictionary represents a project
7373
summary (amount of pending/running/finished jobs and a flag if it
7474
has a capacity to run new jobs).
75-
:rtype: List[dict]
75+
:rtype: :class:`list[dict]`
7676
7777
Usage::
7878

0 commit comments

Comments
 (0)