Skip to content

Commit 643eb0f

Browse files
authored
fix: prevent KeyError when popping an unknown property (#552)
* fix: prevent KeyError when popping an unknown property * fix: typo in version range for mypy
1 parent 6dbdf10 commit 643eb0f

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

algoliasearch/iterators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def __next__(self):
5656
if len(self._raw_response["hits"]):
5757
hit = self._raw_response["hits"].pop(0)
5858

59-
hit.pop("_highlightResult")
59+
if "_highlightResult" in hit:
60+
hit.pop("_highlightResult")
6061

6162
return hit
6263

algoliasearch/iterators_async.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def __anext__(self): # type: ignore
3737
if len(self._raw_response["hits"]):
3838
hit = self._raw_response["hits"].pop(0)
3939

40-
hit.pop("_highlightResult")
40+
if "_highlightResult" in hit:
41+
hit.pop("_highlightResult")
4142

4243
return hit
4344

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typing = >=3.6,<4.0; python_version < '3.5'
1313
asyncio = >=3.4,<4.0
1414
aiohttp = >=2.0,<4.0; python_version >= '3.4.2'
1515
async_timeout = >=2.0,<4.0
16-
mypy = >=0.6,<7.0
16+
mypy = >=0.600,<0.900
1717
flake8 = ==3.8.3
1818
black = ==22.3.0
1919
twine = >=1.13,<2.0

0 commit comments

Comments
 (0)