Skip to content

Commit 3a6b599

Browse files
committed
Refactor to address PR review feedback, revert out-of-scope logic
1 parent fe8ab7b commit 3a6b599

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

serpapi/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def search_archive(self, params: Optional[Dict[str, Any]] = None, **kwargs: Any)
110110
r = self.request("GET", f"/searches/{ search_id }", params=params, assert_200=True, **request_kwargs)
111111
return SerpResults.from_http_response(r, client=self)
112112

113-
def locations(self, params: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Any:
113+
def locations(self, params: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]:
114114
"""Get a list of supported Google locations.
115115
116116
@@ -141,7 +141,7 @@ def locations(self, params: Optional[Dict[str, Any]] = None, **kwargs: Any) -> A
141141
)
142142
return r.json()
143143

144-
def account(self, params: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Any:
144+
def account(self, params: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]:
145145
"""Get SerpApi account information.
146146
147147
:param api_key: the API Key to use for SerpApi.com.

serpapi/models.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ def as_dict(self) -> Dict[str, Any]:
5252
def next_page_url(self) -> Optional[str]:
5353
"""The URL of the next page of results, if any."""
5454

55-
serpapi_pagination: Optional[Dict[str, Any]] = self.data.get("serpapi_pagination")
55+
serpapi_pagination = self.data.get("serpapi_pagination")
5656

5757
if serpapi_pagination:
58-
next_url = serpapi_pagination.get("next")
59-
return next_url if isinstance(next_url, str) else None
58+
return serpapi_pagination.get("next")
6059
return None
6160

6261
def next_page(self) -> Optional[Union["SerpResults", str]]:
@@ -78,11 +77,11 @@ def yield_pages(self, max_pages: int = 1_000) -> Iterator[Union["SerpResults", s
7877
"""
7978

8079
current_page_count = 0
81-
current_page: Union["SerpResults", str, None] = self
80+
current_page = self
8281
while current_page and current_page_count < max_pages:
8382
yield current_page
8483
current_page_count += 1
85-
if isinstance(current_page, SerpResults) and current_page.next_page_url:
84+
if current_page.next_page_url:
8685
current_page = current_page.next_page()
8786
else:
8887
break

0 commit comments

Comments
 (0)