Skip to content

Commit b076bea

Browse files
committed
format code
1 parent 18ad25f commit b076bea

File tree

8 files changed

+39
-11
lines changed

8 files changed

+39
-11
lines changed

ipinfo/details.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def __getattr__(self, attr):
1515
if attr in self.details:
1616
return self.details[attr]
1717
else:
18-
raise AttributeError("{} is not a valid attribute of Details".format(attr))
18+
raise AttributeError(
19+
"{} is not a valid attribute of Details".format(attr)
20+
)
1921

2022
@property
2123
def all(self):

ipinfo/handler.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def getBatchDetails(self, ip_addresses):
6060
for ip_address in ip_addresses:
6161
# If the supplied IP address uses the objects defined in the built-in module ipaddress
6262
# extract the appropriate string notation before formatting the URL
63-
if isinstance(ip_address, IPv4Address) or isinstance(ip_address, IPv6Address):
63+
if isinstance(ip_address, IPv4Address) or isinstance(
64+
ip_address, IPv6Address
65+
):
6466
ip_address = ip_address.exploded
6567

6668
if ip_address in self.cache:
@@ -99,7 +101,9 @@ def _requestDetails(self, ip_address=None):
99101

100102
# If the supplied IP address uses the objects defined in the built-in module ipaddress
101103
# extract the appropriate string notation before formatting the URL
102-
if isinstance(ip_address, IPv4Address) or isinstance(ip_address, IPv6Address):
104+
if isinstance(ip_address, IPv4Address) or isinstance(
105+
ip_address, IPv6Address
106+
):
103107
ip_address = ip_address.exploded
104108

105109
if ip_address not in self.cache:

ipinfo/handler_async.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ async def getDetails(self, ip_address=None):
4949
# If the supplied IP address uses the objects defined in the built-in
5050
# module ipaddress, extract the appropriate string notation before
5151
# formatting the URL.
52-
if isinstance(ip_address, IPv4Address) or isinstance(ip_address, IPv6Address):
52+
if isinstance(ip_address, IPv4Address) or isinstance(
53+
ip_address, IPv6Address
54+
):
5355
ip_address = ip_address.exploded
5456

5557
if ip_address in self.cache:
@@ -81,7 +83,9 @@ async def getBatchDetails(self, ip_addresses):
8183
# If the supplied IP address uses the objects defined in the
8284
# built-in module ipaddress extract the appropriate string notation
8385
# before formatting the URL.
84-
if isinstance(ip_address, IPv4Address) or isinstance(ip_address, IPv6Address):
86+
if isinstance(ip_address, IPv4Address) or isinstance(
87+
ip_address, IPv6Address
88+
):
8589
ip_address = ip_address.exploded
8690

8791
if ip_address in self.cache:
@@ -144,7 +148,10 @@ def _read_coords(self, location):
144148
return lat, lon
145149

146150
def _read_country_names(self, countries_file=None):
147-
"""Read list of countries from specified country file or default file."""
151+
"""
152+
Read list of countries from specified country file or
153+
default file.
154+
"""
148155
if not countries_file:
149156
countries_file = os.path.join(
150157
os.path.dirname(__file__), self.COUNTRY_FILE_DEFAULT

scripts/fmt.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
DIR=`dirname $0`
4+
5+
# Format the project.
6+
7+
black -l 79 $DIR/../ipinfo $DIR/../tests

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
author_email="[email protected]",
1919
license="Apache License 2.0",
2020
packages=["ipinfo", "ipinfo.cache"],
21-
install_requires=["requests", "cachetools"],
21+
install_requires=["requests", "cachetools", "aiohttp<=4"],
2222
include_package_data=True,
2323
zip_safe=False,
2424
)

tests/handler_async_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from ipinfo.handler_async import AsyncHandler
66
import pytest
77

8+
89
@pytest.mark.asyncio
910
async def test_init():
1011
token = "mytesttoken"
@@ -27,7 +28,7 @@ async def test_headers():
2728

2829
@pytest.mark.asyncio
2930
async def test_get_details():
30-
token = os.environ.get('IPINFO_TOKEN', '')
31+
token = os.environ.get("IPINFO_TOKEN", "")
3132
handler = AsyncHandler(token)
3233
details = await handler.getDetails("8.8.8.8")
3334
assert isinstance(details, Details)
@@ -62,7 +63,10 @@ async def test_get_details():
6263
assert privacy["hosting"] == False
6364

6465
abuse = details.abuse
65-
assert abuse["address"] == "US, CA, Mountain View, 1600 Amphitheatre Parkway, 94043"
66+
assert (
67+
abuse["address"]
68+
== "US, CA, Mountain View, 1600 Amphitheatre Parkway, 94043"
69+
)
6670
assert abuse["country"] == "US"
6771
assert abuse["email"] == "[email protected]"
6872
assert abuse["name"] == "Abuse"

tests/handler_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_headers():
2626

2727

2828
def test_get_details():
29-
token = os.environ.get('IPINFO_TOKEN', '')
29+
token = os.environ.get("IPINFO_TOKEN", "")
3030
handler = Handler(token)
3131
details = handler.getDetails("8.8.8.8")
3232
assert isinstance(details, Details)
@@ -61,7 +61,10 @@ def test_get_details():
6161
assert privacy["hosting"] == False
6262

6363
abuse = details.abuse
64-
assert abuse["address"] == "US, CA, Mountain View, 1600 Amphitheatre Parkway, 94043"
64+
assert (
65+
abuse["address"]
66+
== "US, CA, Mountain View, 1600 Amphitheatre Parkway, 94043"
67+
)
6568
assert abuse["country"] == "US"
6669
assert abuse["email"] == "[email protected]"
6770
assert abuse["name"] == "Abuse"

tests/init_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def test_get_handler():
77
handler = ipinfo.getHandler()
88
assert isinstance(handler, Handler)
99

10+
1011
def test_get_handler_async():
1112
handler = ipinfo.getHandlerAsync()
1213
assert isinstance(handler, AsyncHandler)

0 commit comments

Comments
 (0)