Skip to content

Commit 6c04a68

Browse files
committed
cosmetic changes
1 parent 8bb867a commit 6c04a68

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

ipinfo/handler.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ def getBatchDetails(
199199
result = {}
200200
lookup_addresses = []
201201

202-
# check if bogon.
202+
# pre-populate with anything we've got in the cache, and keep around
203+
# the IPs not in the cache.
203204
for ip_address in ip_addresses:
205+
# if the supplied IP address uses the objects defined in the
206+
# built-in module ipaddress extract the appropriate string notation
207+
# before formatting the URL.
204208
if isinstance(ip_address, IPv4Address) or isinstance(
205209
ip_address, IPv6Address
206210
):
@@ -214,17 +218,6 @@ def getBatchDetails(
214218
else:
215219
lookup_addresses.append(ip_address)
216220

217-
# pre-populate with anything we've got in the cache, and keep around
218-
# the IPs not in the cache.
219-
for ip_address in ip_addresses:
220-
# if the supplied IP address uses the objects defined in the
221-
# built-in module ipaddress extract the appropriate string notation
222-
# before formatting the URL.
223-
if isinstance(ip_address, IPv4Address) or isinstance(
224-
ip_address, IPv6Address
225-
):
226-
ip_address = ip_address.exploded
227-
228221
try:
229222
cached_ipaddr = self.cache[cache_key(ip_address)]
230223
result[ip_address] = cached_ipaddr

tests/handler_async_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ def _check_iterative_batch_details(ip, details, token):
162162
@pytest.mark.asyncio
163163
async def test_get_iterative_batch_details(batch_size):
164164
handler, token, ips = _prepare_batch_test()
165-
async for ips, details in handler.getBatchDetailsIter(
166-
ips, batch_size
167-
):
165+
async for ips, details in handler.getBatchDetailsIter(ips, batch_size):
168166
_check_iterative_batch_details(ips, details, token)
169167

170168

tests/handler_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ def test_get_batch_details_total_timeout(batch_size):
163163
@pytest.mark.parametrize("batch_size", [None, 1, 2, 3])
164164
def test_get_iterative_batch_details(batch_size):
165165
handler, token, ips = _prepare_batch_test()
166-
details_iterator = handler.getBatchDetailsIter(
167-
ips, batch_size=batch_size
168-
)
166+
details_iterator = handler.getBatchDetailsIter(ips, batch_size=batch_size)
169167
for details in details_iterator:
170168
_check_iterative_batch_details(details, token)
171169

0 commit comments

Comments
 (0)