Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent KeyError when popping an unknown property #552

Merged
merged 2 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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