Skip to content

Commit 2d65b82

Browse files
committed
Minor clean-up
1 parent 78f472c commit 2d65b82

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

geoip2/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _model_for(self, model_class, ip_address):
100100
record = self.db_reader.get(ip_address)
101101
if record is None:
102102
raise geoip2.errors.AddressNotFoundError(
103-
"The address %s is not in the database." % (ip_address))
103+
"The address %s is not in the database." % ip_address)
104104
record.setdefault('traits', {})['ip_address'] = ip_address
105105
return model_class(record, locales=self.locales)
106106

geoip2/records.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ def __new__(cls, locales, *subdivisions):
433433
obj._locales = locales
434434
return obj
435435

436+
def __init__(self, locales, *subdivisions):
437+
super(Subdivisions, self).__init__()
438+
436439
@property
437440
def most_specific(self):
438441
"""The most specific (smallest) subdivision available.

geoip2/webservice.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __init__(self, user_id, license_key, host='geoip.maxmind.com',
9393
self.locales = locales
9494
self.user_id = user_id
9595
self.license_key = license_key
96-
self._base_uri = 'https://%s/geoip/v2.0' % (host)
96+
self._base_uri = 'https://%s/geoip/v2.0' % host
9797

9898
def city(self, ip_address='me'):
9999
"""This method calls the GeoIP2 Precision City endpoint.
@@ -152,7 +152,7 @@ def _response_for(self, path, model_class, ip_address):
152152
response = requests.get(uri, auth=(self.user_id, self.license_key),
153153
headers={'Accept': 'application/json',
154154
'User-Agent': self._user_agent()})
155-
if (response.status_code == 200): # pylint:disable=E1103
155+
if response.status_code == 200: # pylint:disable=E1103
156156
body = self._handle_success(response, uri)
157157
return model_class(body, locales=self.locales)
158158
else:
@@ -174,9 +174,9 @@ def _handle_success(self, response, uri):
174174
def _handle_error(self, response, uri):
175175
status = response.status_code
176176

177-
if status >= 400 and status < 499:
177+
if 400 <= status < 499:
178178
self._handle_4xx_status(response, status, uri)
179-
elif status >= 500 and status < 599:
179+
elif 500 <= status < 599:
180180
self._handle_5xx_status(status, uri)
181181
else:
182182
self._handle_non_200_status(status, uri)

0 commit comments

Comments
 (0)