Skip to content

Commit

Permalink
fix: prevent KeyError when popping an unknown property (#552)
Browse files Browse the repository at this point in the history
* fix: prevent KeyError when popping an unknown property

* fix: typo in version range for mypy
  • Loading branch information
shortcuts committed Jan 3, 2023
1 parent 6dbdf10 commit 643eb0f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion algoliasearch/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def __next__(self):
if len(self._raw_response["hits"]):
hit = self._raw_response["hits"].pop(0)

hit.pop("_highlightResult")
if "_highlightResult" in hit:
hit.pop("_highlightResult")

return hit

Expand Down
3 changes: 2 additions & 1 deletion algoliasearch/iterators_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def __anext__(self): # type: ignore
if len(self._raw_response["hits"]):
hit = self._raw_response["hits"].pop(0)

hit.pop("_highlightResult")
if "_highlightResult" in hit:
hit.pop("_highlightResult")

return hit

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typing = >=3.6,<4.0; python_version < '3.5'
asyncio = >=3.4,<4.0
aiohttp = >=2.0,<4.0; python_version >= '3.4.2'
async_timeout = >=2.0,<4.0
mypy = >=0.6,<7.0
mypy = >=0.600,<0.900
flake8 = ==3.8.3
black = ==22.3.0
twine = >=1.13,<2.0
Expand Down

0 comments on commit 643eb0f

Please sign in to comment.