Skip to content

Commit 1d5e441

Browse files
committed
fixing the return issues
1 parent c017d0c commit 1d5e441

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

ipinfo/handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def getBatchDetails(
218218
details = {}
219219
details["ip"] = ip_address
220220
details["bogon"] = True
221-
return Details(details)
221+
result[ip_address] = details
222222
else:
223223
lookup_addresses.append(ip_address)
224224

@@ -339,7 +339,7 @@ def getBatchDetailsIter(
339339
details = {}
340340
details["ip"] = ip_address
341341
details["bogon"] = True
342-
yield Details(details)
342+
result[ip_address] = details
343343
else:
344344
lookup_addresses.append(ip_address)
345345

@@ -351,7 +351,7 @@ def getBatchDetailsIter(
351351

352352
# all in cache - exit early.
353353
if len(lookup_addresses) == 0:
354-
yield result.items()
354+
raise StopIteration(result.items())
355355

356356
url = API_URL + "/batch"
357357
headers = handler_utils.get_headers(self.access_token, self.headers)

tests/handler_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,5 +196,4 @@ def test_iterative_bogon_details():
196196
token = os.environ.get("IPINFO_TOKEN", "")
197197
handler = Handler(token)
198198
details = next(handler.getBatchDetailsIter(["127.0.0.1"]))
199-
assert isinstance(details, Details)
200-
assert details.all == {"bogon": True, "ip": "127.0.0.1"}
199+
assert details == {"bogon": True, "ip": "127.0.0.1"}

0 commit comments

Comments
 (0)