Skip to content

Commit 10dd680

Browse files
committed
Fix new pylint errors and run latest YAPF on code
1 parent eefa7cd commit 10dd680

File tree

9 files changed

+159
-188
lines changed

9 files changed

+159
-188
lines changed

geoip2/database.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
"""
77
import inspect
88

9-
import geoip2
10-
import geoip2.models
11-
import geoip2.errors
129
import maxminddb
13-
1410
# pylint: disable=unused-import
1511
from maxminddb import (MODE_AUTO, MODE_MMAP, MODE_MMAP_EXT, MODE_FILE,
1612
MODE_MEMORY)
1713

14+
import geoip2
15+
import geoip2.models
16+
import geoip2.errors
1817

19-
class Reader(object):
2018

19+
class Reader(object):
2120
"""GeoIP2 database Reader object.
2221
2322
Instances of this class provide a reader for the GeoIP2 database format.
@@ -119,8 +118,7 @@ def anonymous_ip(self, ip_address):
119118
120119
"""
121120
return self._flat_model_for(geoip2.models.AnonymousIP,
122-
'GeoIP2-Anonymous-IP',
123-
ip_address)
121+
'GeoIP2-Anonymous-IP', ip_address)
124122

125123
def connection_type(self, ip_address):
126124
"""Get the ConnectionType object for the IP address
@@ -131,8 +129,7 @@ def connection_type(self, ip_address):
131129
132130
"""
133131
return self._flat_model_for(geoip2.models.ConnectionType,
134-
'GeoIP2-Connection-Type',
135-
ip_address)
132+
'GeoIP2-Connection-Type', ip_address)
136133

137134
def domain(self, ip_address):
138135
"""Get the Domain object for the IP address
@@ -142,8 +139,7 @@ def domain(self, ip_address):
142139
:returns: :py:class:`geoip2.models.Domain` object
143140
144141
"""
145-
return self._flat_model_for(geoip2.models.Domain,
146-
'GeoIP2-Domain',
142+
return self._flat_model_for(geoip2.models.Domain, 'GeoIP2-Domain',
147143
ip_address)
148144

149145
def isp(self, ip_address):
@@ -154,8 +150,7 @@ def isp(self, ip_address):
154150
:returns: :py:class:`geoip2.models.ISP` object
155151
156152
"""
157-
return self._flat_model_for(geoip2.models.ISP,
158-
'GeoIP2-ISP',
153+
return self._flat_model_for(geoip2.models.ISP, 'GeoIP2-ISP',
159154
ip_address)
160155

161156
def _get(self, database_type, ip_address):

geoip2/errors.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
class GeoIP2Error(RuntimeError):
9-
109
"""There was a generic error in GeoIP2.
1110
1211
This class represents a generic error. It extends :py:exc:`RuntimeError`
@@ -16,17 +15,14 @@ class GeoIP2Error(RuntimeError):
1615

1716

1817
class AddressNotFoundError(GeoIP2Error):
19-
2018
"""The address you were looking up was not found."""
2119

2220

2321
class AuthenticationError(GeoIP2Error):
24-
2522
"""There was a problem authenticating the request."""
2623

2724

2825
class HTTPError(GeoIP2Error):
29-
3026
"""There was an error when making your HTTP request.
3127
3228
This class represents an HTTP transport error. It extends
@@ -44,10 +40,8 @@ def __init__(self, message, http_status=None, uri=None):
4440

4541

4642
class InvalidRequestError(GeoIP2Error):
47-
4843
"""The request was invalid."""
4944

5045

5146
class OutOfQueriesError(GeoIP2Error):
52-
5347
"""Your account is out of funds for the service queried."""

geoip2/mixins.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55

66
class SimpleEquality(object):
7-
87
"""Naive __dict__ equality mixin"""
98

109
__metaclass__ = ABCMeta
1110

1211
def __eq__(self, other):
13-
return (isinstance(other, self.__class__)
14-
and self.__dict__ == other.__dict__)
12+
return (isinstance(other, self.__class__) and
13+
self.__dict__ == other.__dict__)
1514

1615
def __ne__(self, other):
1716
return not self.__eq__(other)

geoip2/models.py

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

1919

2020
class Country(SimpleEquality):
21-
2221
"""Model for the GeoIP2 Precision: Country and the GeoIP2 Country database
2322
2423
This class provides the following attributes:
@@ -100,7 +99,6 @@ def __repr__(self):
10099

101100

102101
class City(Country):
103-
104102
"""Model for the GeoIP2 Precision: City and the GeoIP2 City database
105103
.. attribute:: city
106104
@@ -176,7 +174,6 @@ def __init__(self, raw_response, locales=None):
176174

177175

178176
class Insights(City):
179-
180177
"""Model for the GeoIP2 Precision: Insights web service endpoint
181178
182179
.. attribute:: city
@@ -241,7 +238,6 @@ class Insights(City):
241238

242239

243240
class SimpleModel(SimpleEquality):
244-
245241
"""Provides basic methods for non-location models"""
246242

247243
__metaclass__ = ABCMeta
@@ -255,7 +251,6 @@ def __repr__(self):
255251

256252

257253
class AnonymousIP(SimpleModel):
258-
259254
"""Model class for the GeoIP2 Anonymous IP
260255
261256
This class provides the following attribute:
@@ -309,7 +304,6 @@ def __init__(self, raw):
309304

310305

311306
class ConnectionType(SimpleModel):
312-
313307
"""Model class for the GeoIP2 Connection-Type
314308
315309
This class provides the following attribute:
@@ -341,7 +335,6 @@ def __init__(self, raw):
341335

342336

343337
class Domain(SimpleModel):
344-
345338
"""Model class for the GeoIP2 Domain
346339
347340
This class provides the following attribute:
@@ -367,7 +360,6 @@ def __init__(self, raw):
367360

368361

369362
class ISP(SimpleModel):
370-
371363
"""Model class for the GeoIP2 ISP
372364
373365
This class provides the following attribute:

geoip2/records.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111

1212

1313
class Record(SimpleEquality):
14-
1514
"""All records are subclasses of the abstract class ``Record``"""
1615
__metaclass__ = ABCMeta
1716

18-
_valid_attributes = None
17+
_valid_attributes = set()
1918

2019
def __init__(self, **kwargs):
2120
valid_args = dict((k, kwargs.get(k)) for k in self._valid_attributes)
@@ -33,7 +32,6 @@ def __repr__(self):
3332

3433

3534
class PlaceRecord(Record):
36-
3735
"""All records with :py:attr:`names` subclass :py:class:`PlaceRecord`"""
3836
__metaclass__ = ABCMeta
3937

@@ -49,12 +47,12 @@ def __init__(self, locales=None, **kwargs):
4947
def name(self):
5048
"""Dict with locale codes as keys and localized name as value"""
5149
# pylint:disable=E1101
52-
return next((self.names.get(x) for x in self._locales if x in
53-
self.names), None)
50+
return next(
51+
(self.names.get(x) for x in self._locales
52+
if x in self.names), None)
5453

5554

5655
class City(PlaceRecord):
57-
5856
"""Contains data for the city record associated with an IP address
5957
6058
This class contains the city-level data associated with an IP address.
@@ -96,7 +94,6 @@ class City(PlaceRecord):
9694

9795

9896
class Continent(PlaceRecord):
99-
10097
"""Contains data for the continent record associated with an IP address
10198
10299
This class contains the continent-level data associated with an IP
@@ -137,7 +134,6 @@ class Continent(PlaceRecord):
137134

138135

139136
class Country(PlaceRecord):
140-
141137
"""Contains data for the country record associated with an IP address
142138
143139
This class contains the country-level data associated with an IP address.
@@ -186,7 +182,6 @@ class Country(PlaceRecord):
186182

187183

188184
class RepresentedCountry(Country):
189-
190185
"""Contains data for the represented country associated with an IP address
191186
192187
This class contains the country-level data associated with an IP address
@@ -241,12 +236,11 @@ class RepresentedCountry(Country):
241236
:type: unicode
242237
243238
"""
244-
_valid_attributes = set(['confidence', 'geoname_id', 'iso_code',
245-
'names', 'type'])
239+
_valid_attributes = set(['confidence', 'geoname_id', 'iso_code', 'names',
240+
'type'])
246241

247242

248243
class Location(Record):
249-
250244
"""Contains data for the location record associated with an IP address
251245
252246
This class contains the location data associated with an IP address.
@@ -314,7 +308,6 @@ class Location(Record):
314308

315309

316310
class MaxMind(Record):
317-
318311
"""Contains data related to your MaxMind account
319312
320313
Attributes:
@@ -331,7 +324,6 @@ class MaxMind(Record):
331324

332325

333326
class Postal(Record):
334-
335327
"""Contains data for the postal record associated with an IP address
336328
337329
This class contains the postal data associated with an IP address.
@@ -361,7 +353,6 @@ class Postal(Record):
361353

362354

363355
class Subdivision(PlaceRecord):
364-
365356
"""Contains data for the subdivisions associated with an IP address
366357
367358
This class contains the subdivision data associated with an IP address.
@@ -411,7 +402,6 @@ class Subdivision(PlaceRecord):
411402

412403

413404
class Subdivisions(tuple):
414-
415405
"""A tuple-like collection of subdivisions associated with an IP address
416406
417407
This class contains the subdivisions of the country associated with the
@@ -422,6 +412,7 @@ class Subdivisions(tuple):
422412
423413
This attribute is returned by ``city`` and ``insights``.
424414
"""
415+
425416
def __new__(cls, locales, *subdivisions):
426417
subdivisions = [Subdivision(locales, **x) for x in subdivisions]
427418
obj = super(cls, Subdivisions).__new__(cls, subdivisions)
@@ -447,7 +438,6 @@ def most_specific(self):
447438

448439

449440
class Traits(Record):
450-
451441
""" Contains data for the traits record associated with an IP address
452442
453443
This class contains the traits data associated with an IP address.
@@ -558,15 +548,10 @@ class Traits(Record):
558548
:type: unicode
559549
560550
"""
561-
_valid_attributes = set(['autonomous_system_number',
562-
'autonomous_system_organization',
563-
'domain',
564-
'is_anonymous_proxy',
565-
'is_satellite_provider',
566-
'isp',
567-
'ip_address',
568-
'organization',
569-
'user_type'])
551+
_valid_attributes = set(
552+
['autonomous_system_number', 'autonomous_system_organization',
553+
'domain', 'is_anonymous_proxy', 'is_satellite_provider', 'isp',
554+
'ip_address', 'organization', 'user_type'])
570555

571556
def __init__(self, **kwargs):
572557
for k in ['is_anonymous_proxy', 'is_satellite_provider']:

0 commit comments

Comments
 (0)