Skip to content

Commit ea3a130

Browse files
committed
PEP 257 fixes
1 parent 5df4909 commit ea3a130

File tree

3 files changed

+50
-36
lines changed

3 files changed

+50
-36
lines changed

geoip2/database.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Reader(object):
4141
"""
4242

4343
def __init__(self, filename, locales=None, mode=MODE_AUTO):
44-
"""Create GeoIP2 Reader
44+
"""Create GeoIP2 Reader.
4545
4646
:param filename: The path to the GeoIP2 database.
4747
:param locales: This is list of locale codes. This argument will be
@@ -89,7 +89,7 @@ def __exit__(self, exc_type, exc_value, traceback):
8989
self.close()
9090

9191
def country(self, ip_address):
92-
"""Get the Country object for the IP address
92+
"""Get the Country object for the IP address.
9393
9494
:param ip_address: IPv4 or IPv6 address as a string.
9595
@@ -100,7 +100,7 @@ def country(self, ip_address):
100100
return self._model_for(geoip2.models.Country, 'Country', ip_address)
101101

102102
def city(self, ip_address):
103-
"""Get the City object for the IP address
103+
"""Get the City object for the IP address.
104104
105105
:param ip_address: IPv4 or IPv6 address as a string.
106106
@@ -110,7 +110,7 @@ def city(self, ip_address):
110110
return self._model_for(geoip2.models.City, 'City', ip_address)
111111

112112
def anonymous_ip(self, ip_address):
113-
"""Get the AnonymousIP object for the IP address
113+
"""Get the AnonymousIP object for the IP address.
114114
115115
:param ip_address: IPv4 or IPv6 address as a string.
116116
@@ -121,7 +121,7 @@ def anonymous_ip(self, ip_address):
121121
'GeoIP2-Anonymous-IP', ip_address)
122122

123123
def connection_type(self, ip_address):
124-
"""Get the ConnectionType object for the IP address
124+
"""Get the ConnectionType object for the IP address.
125125
126126
:param ip_address: IPv4 or IPv6 address as a string.
127127
@@ -132,7 +132,7 @@ def connection_type(self, ip_address):
132132
'GeoIP2-Connection-Type', ip_address)
133133

134134
def domain(self, ip_address):
135-
"""Get the Domain object for the IP address
135+
"""Get the Domain object for the IP address.
136136
137137
:param ip_address: IPv4 or IPv6 address as a string.
138138
@@ -143,7 +143,7 @@ def domain(self, ip_address):
143143
ip_address)
144144

145145
def enterprise(self, ip_address):
146-
"""Get the Enterprise object for the IP address
146+
"""Get the Enterprise object for the IP address.
147147
148148
:param ip_address: IPv4 or IPv6 address as a string.
149149
@@ -154,7 +154,7 @@ def enterprise(self, ip_address):
154154
ip_address)
155155

156156
def isp(self, ip_address):
157-
"""Get the ISP object for the IP address
157+
"""Get the ISP object for the IP address.
158158
159159
:param ip_address: IPv4 or IPv6 address as a string.
160160
@@ -187,13 +187,13 @@ def _flat_model_for(self, model_class, types, ip_address):
187187
return model_class(record)
188188

189189
def metadata(self):
190-
"""The metadata for the open database
190+
"""The metadata for the open database.
191191
192192
:returns: :py:class:`maxminddb.reader.Metadata` object
193193
"""
194194
return self._db_reader.metadata()
195195

196196
def close(self):
197-
"""Closes the GeoIP2 database"""
197+
"""Closes the GeoIP2 database."""
198198

199199
self._db_reader.close()

geoip2/models.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
class Country(SimpleEquality):
21-
"""Model for the GeoIP2 Precision: Country and the GeoIP2 Country database
21+
"""Model for the GeoIP2 Precision: Country and the GeoIP2 Country database.
2222
2323
This class provides the following attributes:
2424
@@ -99,7 +99,8 @@ def __repr__(self):
9999

100100

101101
class City(Country):
102-
"""Model for the GeoIP2 Precision: City and the GeoIP2 City database
102+
"""Model for the GeoIP2 Precision: City and the GeoIP2 City database.
103+
103104
.. attribute:: city
104105
105106
City object for the requested IP address.
@@ -174,7 +175,7 @@ def __init__(self, raw_response, locales=None):
174175

175176

176177
class Insights(City):
177-
"""Model for the GeoIP2 Precision: Insights web service endpoint
178+
"""Model for the GeoIP2 Precision: Insights web service endpoint.
178179
179180
.. attribute:: city
180181
@@ -238,7 +239,7 @@ class Insights(City):
238239

239240

240241
class Enterprise(City):
241-
"""Model for the GeoIP2 Enterprise database
242+
"""Model for the GeoIP2 Enterprise database.
242243
243244
.. attribute:: city
244245
@@ -315,7 +316,7 @@ def __repr__(self):
315316

316317

317318
class AnonymousIP(SimpleModel):
318-
"""Model class for the GeoIP2 Anonymous IP
319+
"""Model class for the GeoIP2 Anonymous IP.
319320
320321
This class provides the following attribute:
321322
@@ -368,7 +369,7 @@ def __init__(self, raw):
368369

369370

370371
class ConnectionType(SimpleModel):
371-
"""Model class for the GeoIP2 Connection-Type
372+
"""Model class for the GeoIP2 Connection-Type.
372373
373374
This class provides the following attribute:
374375
@@ -399,7 +400,7 @@ def __init__(self, raw):
399400

400401

401402
class Domain(SimpleModel):
402-
"""Model class for the GeoIP2 Domain
403+
"""Model class for the GeoIP2 Domain.
403404
404405
This class provides the following attribute:
405406
@@ -424,7 +425,7 @@ def __init__(self, raw):
424425

425426

426427
class ISP(SimpleModel):
427-
"""Model class for the GeoIP2 ISP
428+
"""Model class for the GeoIP2 ISP.
428429
429430
This class provides the following attribute:
430431

geoip2/records.py

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
=======
55
66
"""
7+
78
# pylint:disable=R0903
89
from abc import ABCMeta
910

1011
from geoip2.mixins import SimpleEquality
1112

1213

1314
class Record(SimpleEquality):
14-
"""All records are subclasses of the abstract class ``Record``"""
15+
"""All records are subclasses of the abstract class ``Record``."""
16+
1517
__metaclass__ = ABCMeta
1618

1719
_valid_attributes = set()
@@ -32,7 +34,8 @@ def __repr__(self):
3234

3335

3436
class PlaceRecord(Record):
35-
"""All records with :py:attr:`names` subclass :py:class:`PlaceRecord`"""
37+
"""All records with :py:attr:`names` subclass :py:class:`PlaceRecord`."""
38+
3639
__metaclass__ = ABCMeta
3740

3841
def __init__(self, locales=None, **kwargs):
@@ -45,15 +48,15 @@ def __init__(self, locales=None, **kwargs):
4548

4649
@property
4750
def name(self):
48-
"""Dict with locale codes as keys and localized name as value"""
51+
"""Dict with locale codes as keys and localized name as value."""
4952
# pylint:disable=E1101
5053
return next(
5154
(self.names.get(x) for x in self._locales
5255
if x in self.names), None)
5356

5457

5558
class City(PlaceRecord):
56-
"""Contains data for the city record associated with an IP address
59+
"""Contains data for the city record associated with an IP address.
5760
5861
This class contains the city-level data associated with an IP address.
5962
@@ -90,11 +93,12 @@ class City(PlaceRecord):
9093
:type: dict
9194
9295
"""
96+
9397
_valid_attributes = set(['confidence', 'geoname_id', 'names'])
9498

9599

96100
class Continent(PlaceRecord):
97-
"""Contains data for the continent record associated with an IP address
101+
"""Contains data for the continent record associated with an IP address.
98102
99103
This class contains the continent-level data associated with an IP
100104
address.
@@ -130,11 +134,12 @@ class Continent(PlaceRecord):
130134
:type: dict
131135
132136
"""
137+
133138
_valid_attributes = set(['code', 'geoname_id', 'names'])
134139

135140

136141
class Country(PlaceRecord):
137-
"""Contains data for the country record associated with an IP address
142+
"""Contains data for the country record associated with an IP address.
138143
139144
This class contains the country-level data associated with an IP address.
140145
@@ -178,11 +183,12 @@ class Country(PlaceRecord):
178183
:type: dict
179184
180185
"""
186+
181187
_valid_attributes = set(['confidence', 'geoname_id', 'iso_code', 'names'])
182188

183189

184190
class RepresentedCountry(Country):
185-
"""Contains data for the represented country associated with an IP address
191+
"""Contains data for the represented country associated with an IP address.
186192
187193
This class contains the country-level data associated with an IP address
188194
for the IP's represented country. The represented country is the country
@@ -236,12 +242,13 @@ class RepresentedCountry(Country):
236242
:type: unicode
237243
238244
"""
245+
239246
_valid_attributes = set(['confidence', 'geoname_id', 'iso_code', 'names',
240247
'type'])
241248

242249

243250
class Location(Record):
244-
"""Contains data for the location record associated with an IP address
251+
"""Contains data for the location record associated with an IP address.
245252
246253
This class contains the location data associated with an IP address.
247254
@@ -304,13 +311,14 @@ class Location(Record):
304311
:type: unicode
305312
306313
"""
314+
307315
_valid_attributes = set(['average_income', 'accuracy_radius', 'latitude',
308316
'longitude', 'metro_code', 'population_density',
309317
'postal_code', 'postal_confidence', 'time_zone'])
310318

311319

312320
class MaxMind(Record):
313-
"""Contains data related to your MaxMind account
321+
"""Contains data related to your MaxMind account.
314322
315323
Attributes:
316324
@@ -322,11 +330,12 @@ class MaxMind(Record):
322330
:type: int
323331
324332
"""
333+
325334
_valid_attributes = set(['queries_remaining'])
326335

327336

328337
class Postal(Record):
329-
"""Contains data for the postal record associated with an IP address
338+
"""Contains data for the postal record associated with an IP address.
330339
331340
This class contains the postal data associated with an IP address.
332341
@@ -352,11 +361,12 @@ class Postal(Record):
352361
:type: int
353362
354363
"""
364+
355365
_valid_attributes = set(['code', 'confidence'])
356366

357367

358368
class Subdivision(PlaceRecord):
359-
"""Contains data for the subdivisions associated with an IP address
369+
"""Contains data for the subdivisions associated with an IP address.
360370
361371
This class contains the subdivision data associated with an IP address.
362372
@@ -402,11 +412,12 @@ class Subdivision(PlaceRecord):
402412
:type: dict
403413
404414
"""
415+
405416
_valid_attributes = set(['confidence', 'geoname_id', 'iso_code', 'names'])
406417

407418

408419
class Subdivisions(tuple):
409-
"""A tuple-like collection of subdivisions associated with an IP address
420+
"""A tuple-like collection of subdivisions associated with an IP address.
410421
411422
This class contains the subdivisions of the country associated with the
412423
IP address from largest to smallest.
@@ -430,10 +441,10 @@ def __init__(self, locales, *subdivisions): # pylint:disable=W0613
430441
def most_specific(self):
431442
"""The most specific (smallest) subdivision available.
432443
433-
If there are no :py:class:`Subdivision` objects for the response,
434-
this returns an empty :py:class:`Subdivision`.
444+
If there are no :py:class:`Subdivision` objects for the response,
445+
this returns an empty :py:class:`Subdivision`.
435446
436-
:type: :py:class:`Subdivision`
447+
:type: :py:class:`Subdivision`
437448
"""
438449
try:
439450
return self[-1]
@@ -442,7 +453,7 @@ def most_specific(self):
442453

443454

444455
class Traits(Record):
445-
""" Contains data for the traits record associated with an IP address
456+
"""Contains data for the traits record associated with an IP address.
446457
447458
This class contains the traits data associated with an IP address.
448459
@@ -534,7 +545,8 @@ class Traits(Record):
534545
.. deprecated:: 2.2.0
535546
Due to the increased coverage by mobile carriers, very few
536547
satellite providers now serve multiple countries. As a result, the
537-
output does not provide sufficiently relevant data for us to maintain it.
548+
output does not provide sufficiently relevant data for us to maintain
549+
it.
538550
539551
.. attribute:: isp
540552
@@ -578,7 +590,8 @@ class Traits(Record):
578590
579591
:type: unicode
580592
581-
"""
593+
"""
594+
582595
_valid_attributes = set(
583596
['autonomous_system_number', 'autonomous_system_organization',
584597
'connection_type', 'domain', 'is_anonymous_proxy',

0 commit comments

Comments
 (0)