Skip to content

Commit 9f5cb7f

Browse files
committed
PR comments.
1 parent 06d40cc commit 9f5cb7f

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/citrine/_rest/pageable.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from functools import partial
21
from typing import Optional, Iterable, Dict, Tuple, Callable, Union, Sequence
32
from uuid import UUID
43

@@ -26,6 +25,8 @@ def _fetch_page(self,
2625
per_page: Optional[int] = None,
2726
json_body: Optional[dict] = None,
2827
additional_params: Optional[dict] = None,
28+
*,
29+
version: Optional[str] = None
2930
) -> Tuple[Iterable[dict], str]:
3031
"""
3132
Fetch visible elements. This does not handle pagination.
@@ -59,6 +60,9 @@ def _fetch_page(self,
5960
}
6061
additional_params: dict, optional
6162
A dict that allows extra parameters to be added to the request parameters
63+
version: str, optional
64+
A string denoting which version of the underlying API endpoint will be called. Defaults
65+
to the collection's API version.
6266
6367
Returns
6468
-------
@@ -69,15 +73,16 @@ def _fetch_page(self,
6973
7074
"""
7175
# To avoid setting defaults -> reduce mutation risk, and to make more extensible
72-
path = self._get_path() if path is None else path
73-
fetch_func = fetch_func or partial(self.session.get_resource, version=self._api_version)
74-
json_body = {} if json_body is None else json_body
76+
path = path or self._get_path()
77+
fetch_func = fetch_func or self.session.get_resource
78+
json_body = json_body or {}
7579

76-
module_type = getattr(self, '_module_type', None)
77-
params = self._page_params(page, per_page, module_type)
80+
params = self._page_params(page, per_page)
7881
params.update(additional_params or {})
7982

80-
data = fetch_func(path, params=params, **json_body)
83+
version = version or self._api_version
84+
85+
data = fetch_func(path, params=params, version=version, **json_body)
8186

8287
try:
8388
next_uri = data.get('next', "")

src/citrine/resources/predictor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ def _list_base(self, *, per_page: int = 100, archived: Optional[bool] = None):
373373
filters["archived"] = archived
374374

375375
fetcher = partial(self._fetch_page,
376-
fetch_func=partial(self.session.get_resource, version="v4"),
377-
additional_params=filters)
376+
additional_params=filters,
377+
version="v4")
378378
return self._paginator.paginate(page_fetcher=fetcher,
379379
collection_builder=self._build_collection_elements,
380380
per_page=per_page)

0 commit comments

Comments
 (0)