Skip to content

Commit 2f33739

Browse files
committed
add type annotations to page
1 parent 5ca5ed3 commit 2f33739

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/msgraph_core/models/page_result.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
from kiota_abstractions.serialization.serialization_writer \
1616
import SerializationWriter # type: ignore
1717
from kiota_abstractions.serialization.parse_node import ParseNode # type: ignore
18-
from typing import TypeVar, List, Optional
18+
from typing import TypeVar, List, Optional, Generic
1919

20-
T = TypeVar('T', bound=Parsable)
20+
T = TypeVar('T')
2121

2222

23-
class PageResult(Parsable):
23+
class PageResult(Parsable, Generic[T]):
2424
"""
2525
Represents a page of items in a paged response.
2626
"""

src/msgraph_core/tasks/page_iterator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
and models modules.
1818
"""
1919

20-
from typing import Callable, Optional, Union, Dict
20+
from typing import Callable, Optional, Union, Dict, Any
2121

2222
from typing import TypeVar
2323
from requests.exceptions import InvalidURL # type: ignore
@@ -74,10 +74,10 @@ def __init__(
7474
self.object_type = self.current_page.value[
7575
0].__class__.__name__ if self.current_page.value else None
7676
page = self.current_page
77-
self.next_link = response.get('@odata.nextLink', '') if isinstance(
77+
self._next_link = response.get('@odata.nextLink', '') if isinstance(
7878
response, dict
7979
) else getattr(response, '@odata.nextLink', '')
80-
self.delta_link = response.get('@odata.deltaLink', '') if isinstance(
80+
self._delta_link = response.get('@odata.deltaLink', '') if isinstance(
8181
response, dict
8282
) else getattr(response, '@odata.deltaLink', '')
8383

@@ -98,11 +98,11 @@ def set_headers(self, headers: dict) -> None:
9898

9999
@property
100100
def delta_link(self):
101-
return self.delta_link
101+
return self._delta_link
102102

103103
@property
104104
def next_link(self):
105-
return self.next_link
105+
return self._next_link
106106

107107
def set_request_options(self, request_options: list) -> None:
108108
"""
@@ -140,7 +140,7 @@ async def next(self) -> Optional[PageResult]:
140140
if not self.current_page.odata_next_link:
141141
return None
142142
response = self.convert_to_page(await self.fetch_next_page())
143-
page = PageResult()
143+
page: PageResult[Any] = PageResult()
144144
page.odata_next_link = response.odata_next_link
145145
page.set_value(response.get('value', []) if isinstance(response, dict) else [])
146146
return page
@@ -175,7 +175,7 @@ def convert_to_page(response: Union[T, list, object]) -> PageResult:
175175
parsable_page, dict
176176
) else getattr(parsable_page, 'odata_next_link', '')
177177

178-
page = PageResult()
178+
page: PageResult[Any] = PageResult()
179179
page.odata_next_link = next_link
180180
page.set_value(value)
181181
return page

0 commit comments

Comments
 (0)