Skip to content

Commit abc0f66

Browse files
committed
fix: Optional[str] for python 3.9
1 parent 1fd648c commit abc0f66

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

ibmcloudant/features/pagination.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from enum import auto, Enum
2727
from functools import partial
2828
from types import MappingProxyType
29-
from typing import Generic, Protocol, TypeVar
29+
from typing import Generic, Optional, Protocol, TypeVar
3030

3131
from ibm_cloud_sdk_core import DetailedResponse
3232
from ibmcloudant.cloudant_v1 import CloudantV1,\
@@ -307,7 +307,7 @@ class _KeyPageIterator(_BasePageIterator, Generic[K]):
307307

308308
def __init__(self, client: CloudantV1, operation: Callable[..., DetailedResponse], opts: dict):
309309
super().__init__(client, operation, ['start_key', 'start_key_doc_id'], opts)
310-
self._boundary_failure: str | None = None
310+
self._boundary_failure: Optional[str] = None
311311

312312
def _next_request(self) -> list[I]:
313313
if self._boundary_failure is not None:
@@ -318,7 +318,7 @@ def _next_request(self) -> list[I]:
318318
if len(items) > 0:
319319
# Get, but don't remove the last item from the list
320320
penultimate_item: I = items[-1]
321-
self._boundary_failure: str | None = self.check_boundary(penultimate_item, last_item)
321+
self._boundary_failure: Optional[str] = self.check_boundary(penultimate_item, last_item)
322322
return items
323323

324324
def _get_next_page_options(self, result: R) -> dict:
@@ -336,7 +336,7 @@ def _page_size_from_opts_limit(self, opts:dict) -> int:
336336
return super()._page_size_from_opts_limit(opts) + 1
337337

338338
@abstractmethod
339-
def check_boundary(self, penultimate_item: I, last_item: I) -> str | None:
339+
def check_boundary(self, penultimate_item: I, last_item: I) -> Optional[str]:
340340
raise NotImplementedError()
341341

342342
class _BookmarkPageIterator(_BasePageIterator):
@@ -358,7 +358,7 @@ def _get_next_page_options(self, result: R) -> dict:
358358
del opts['start_key_doc_id']
359359
return opts
360360

361-
def check_boundary(self, penultimate_item: I, last_item: I) -> str | None:
361+
def check_boundary(self, penultimate_item: I, last_item: I) -> Optional[str]:
362362
# IDs are always unique in _all_docs pagers so return None
363363
return None
364364

@@ -418,7 +418,7 @@ class _ViewBasePageIterator(_KeyPageIterator[any]):
418418
def _result_converter(self):
419419
return ViewResult.from_dict
420420

421-
def check_boundary(self, penultimate_item: I, last_item: I) -> str | None:
421+
def check_boundary(self, penultimate_item: I, last_item: I) -> Optional[str]:
422422
if penultimate_item.id == (boundary_id := last_item.id) \
423423
and penultimate_item.key == (boundary_key := last_item.key):
424424
return f'Cannot paginate on a boundary containing identical keys {boundary_key} and document IDs {boundary_id}'

0 commit comments

Comments
 (0)