8
8
9
9
# pylint:disable=too-many-lines,too-many-instance-attributes,too-many-locals
10
10
from collections .abc import Sequence
11
- from typing import Dict , List , Optional
11
+ from typing import Optional
12
12
13
13
import geoip2 .models
14
14
import geoip2 .records
17
17
18
18
class _Serializable (SimpleEquality ):
19
19
def to_dict (self ):
20
- """Returns a dict of the object suitable for serialization"""
20
+ """Returns a dict of the object suitable for serialization. """
21
21
result = {}
22
22
for key , value in self .__dict__ .items ():
23
23
if hasattr (value , "to_dict" ) and callable (value .to_dict ):
@@ -83,7 +83,9 @@ class IPRiskReason(_Serializable):
83
83
code : Optional [str ]
84
84
reason : Optional [str ]
85
85
86
- def __init__ (self , code : Optional [str ] = None , reason : Optional [str ] = None ):
86
+ def __init__ (
87
+ self , code : Optional [str ] = None , reason : Optional [str ] = None
88
+ ) -> None :
87
89
self .code = code
88
90
self .reason = reason
89
91
@@ -197,16 +199,16 @@ class IPAddress(geoip2.models.Insights):
197
199
198
200
location : GeoIP2Location
199
201
risk : Optional [float ]
200
- risk_reasons : List [IPRiskReason ]
202
+ risk_reasons : list [IPRiskReason ]
201
203
202
204
def __init__ (
203
205
self ,
204
206
locales : Optional [Sequence [str ]],
205
207
* ,
206
- country : Optional [Dict ] = None ,
207
- location : Optional [Dict ] = None ,
208
+ country : Optional [dict ] = None ,
209
+ location : Optional [dict ] = None ,
208
210
risk : Optional [float ] = None ,
209
- risk_reasons : Optional [List [ Dict ]] = None ,
211
+ risk_reasons : Optional [list [ dict ]] = None ,
210
212
** kwargs ,
211
213
) -> None :
212
214
# For raw attribute
@@ -238,7 +240,7 @@ class ScoreIPAddress(_Serializable):
238
240
239
241
risk : Optional [float ]
240
242
241
- def __init__ (self , * , risk : Optional [float ] = None , ** _ ):
243
+ def __init__ (self , * , risk : Optional [float ] = None , ** _ ) -> None :
242
244
self .risk = risk
243
245
244
246
@@ -293,7 +295,7 @@ def __init__(
293
295
phone_number : Optional [str ] = None ,
294
296
matches_provided_phone_number : Optional [bool ] = None ,
295
297
** _ ,
296
- ):
298
+ ) -> None :
297
299
self .name = name
298
300
self .matches_provided_name = matches_provided_name
299
301
self .phone_number = phone_number
@@ -353,7 +355,7 @@ def __init__(
353
355
last_seen : Optional [str ] = None ,
354
356
local_time : Optional [str ] = None ,
355
357
** _ ,
356
- ):
358
+ ) -> None :
357
359
self .confidence = confidence
358
360
self .id = id
359
361
self .last_seen = last_seen
@@ -403,7 +405,7 @@ def __init__(
403
405
reason : Optional [str ] = None ,
404
406
rule_label : Optional [str ] = None ,
405
407
** _ ,
406
- ):
408
+ ) -> None :
407
409
self .action = action
408
410
self .reason = reason
409
411
self .rule_label = rule_label
@@ -424,7 +426,7 @@ class EmailDomain(_Serializable):
424
426
425
427
first_seen : Optional [str ]
426
428
427
- def __init__ (self , * , first_seen : Optional [str ] = None , ** _ ):
429
+ def __init__ (self , * , first_seen : Optional [str ] = None , ** _ ) -> None :
428
430
self .first_seen = first_seen
429
431
430
432
@@ -478,12 +480,12 @@ class Email(_Serializable):
478
480
479
481
def __init__ (
480
482
self ,
481
- domain : Optional [Dict ] = None ,
483
+ domain : Optional [dict ] = None ,
482
484
first_seen : Optional [str ] = None ,
483
485
is_disposable : Optional [bool ] = None ,
484
486
is_free : Optional [bool ] = None ,
485
487
is_high_risk : Optional [bool ] = None ,
486
- ):
488
+ ) -> None :
487
489
self .domain = EmailDomain (** (domain or {}))
488
490
self .first_seen = first_seen
489
491
self .is_disposable = is_disposable
@@ -565,7 +567,7 @@ class CreditCard(_Serializable):
565
567
566
568
def __init__ (
567
569
self ,
568
- issuer : Optional [Dict ] = None ,
570
+ issuer : Optional [dict ] = None ,
569
571
country : Optional [str ] = None ,
570
572
brand : Optional [str ] = None ,
571
573
is_business : Optional [bool ] = None ,
@@ -574,7 +576,7 @@ def __init__(
574
576
is_virtual : Optional [bool ] = None ,
575
577
# pylint:disable=redefined-builtin
576
578
type : Optional [str ] = None ,
577
- ):
579
+ ) -> None :
578
580
self .issuer = Issuer (** (issuer or {}))
579
581
self .country = country
580
582
self .brand = brand
@@ -643,7 +645,7 @@ def __init__(
643
645
distance_to_ip_location : Optional [int ] = None ,
644
646
is_in_ip_country : Optional [bool ] = None ,
645
647
** _ ,
646
- ):
648
+ ) -> None :
647
649
self .is_postal_in_city = is_postal_in_city
648
650
self .latitude = latitude
649
651
self .longitude = longitude
@@ -730,7 +732,7 @@ def __init__(
730
732
is_high_risk : Optional [bool ] = None ,
731
733
distance_to_billing_address : Optional [int ] = None ,
732
734
** _ ,
733
- ):
735
+ ) -> None :
734
736
self .is_postal_in_city = is_postal_in_city
735
737
self .latitude = latitude
736
738
self .longitude = longitude
@@ -790,7 +792,7 @@ def __init__(
790
792
network_operator : Optional [str ] = None ,
791
793
number_type : Optional [str ] = None ,
792
794
** _ ,
793
- ):
795
+ ) -> None :
794
796
self .country = country
795
797
self .is_voip = is_voip
796
798
self .network_operator = network_operator
@@ -838,7 +840,7 @@ def __init__(
838
840
warning : Optional [str ] = None ,
839
841
input_pointer : Optional [str ] = None ,
840
842
** _ ,
841
- ):
843
+ ) -> None :
842
844
self .code = code
843
845
self .warning = warning
844
846
self .input_pointer = input_pointer
@@ -1061,7 +1063,7 @@ def __init__(
1061
1063
shipping_address_distance_to_ip_location : Optional [float ] = None ,
1062
1064
time_of_day : Optional [float ] = None ,
1063
1065
** _ ,
1064
- ):
1066
+ ) -> None :
1065
1067
self .avs_result = avs_result
1066
1068
self .billing_address = billing_address
1067
1069
self .billing_address_distance_to_ip_location = (
@@ -1180,7 +1182,7 @@ def __init__(
1180
1182
code : Optional [str ] = None ,
1181
1183
reason : Optional [str ] = None ,
1182
1184
** _ ,
1183
- ):
1185
+ ) -> None :
1184
1186
self .code = code
1185
1187
self .reason = reason
1186
1188
@@ -1207,15 +1209,15 @@ class RiskScoreReason(_Serializable):
1207
1209
"""
1208
1210
1209
1211
multiplier : float
1210
- reasons : List [Reason ]
1212
+ reasons : list [Reason ]
1211
1213
1212
1214
def __init__ (
1213
1215
self ,
1214
1216
* ,
1215
1217
multiplier : float ,
1216
- reasons : Optional [List ] = None ,
1218
+ reasons : Optional [list ] = None ,
1217
1219
** _ ,
1218
- ):
1220
+ ) -> None :
1219
1221
self .multiplier = multiplier
1220
1222
self .reasons = [Reason (** x ) for x in reasons or []]
1221
1223
@@ -1362,32 +1364,32 @@ class Factors(_Serializable):
1362
1364
shipping_address : ShippingAddress
1363
1365
shipping_phone : Phone
1364
1366
subscores : Subscores
1365
- warnings : List [ServiceWarning ]
1366
- risk_score_reasons : List [RiskScoreReason ]
1367
+ warnings : list [ServiceWarning ]
1368
+ risk_score_reasons : list [RiskScoreReason ]
1367
1369
1368
1370
def __init__ (
1369
1371
self ,
1370
1372
locales : Sequence [str ],
1371
1373
* ,
1372
- billing_address : Optional [Dict ] = None ,
1373
- billing_phone : Optional [Dict ] = None ,
1374
- credit_card : Optional [Dict ] = None ,
1375
- disposition : Optional [Dict ] = None ,
1374
+ billing_address : Optional [dict ] = None ,
1375
+ billing_phone : Optional [dict ] = None ,
1376
+ credit_card : Optional [dict ] = None ,
1377
+ disposition : Optional [dict ] = None ,
1376
1378
funds_remaining : float ,
1377
- device : Optional [Dict ] = None ,
1378
- email : Optional [Dict ] = None ,
1379
+ device : Optional [dict ] = None ,
1380
+ email : Optional [dict ] = None ,
1379
1381
# pylint:disable=redefined-builtin
1380
1382
id : str ,
1381
- ip_address : Optional [Dict ] = None ,
1383
+ ip_address : Optional [dict ] = None ,
1382
1384
queries_remaining : int ,
1383
1385
risk_score : float ,
1384
- shipping_address : Optional [Dict ] = None ,
1385
- shipping_phone : Optional [Dict ] = None ,
1386
- subscores : Optional [Dict ] = None ,
1387
- warnings : Optional [List [ Dict ]] = None ,
1388
- risk_score_reasons : Optional [List [ Dict ]] = None ,
1386
+ shipping_address : Optional [dict ] = None ,
1387
+ shipping_phone : Optional [dict ] = None ,
1388
+ subscores : Optional [dict ] = None ,
1389
+ warnings : Optional [list [ dict ]] = None ,
1390
+ risk_score_reasons : Optional [list [ dict ]] = None ,
1389
1391
** _ ,
1390
- ):
1392
+ ) -> None :
1391
1393
self .billing_address = BillingAddress (** (billing_address or {}))
1392
1394
self .billing_phone = Phone (** (billing_phone or {}))
1393
1395
self .credit_card = CreditCard (** (credit_card or {}))
@@ -1529,29 +1531,29 @@ class Insights(_Serializable):
1529
1531
risk_score : float
1530
1532
shipping_address : ShippingAddress
1531
1533
shipping_phone : Phone
1532
- warnings : List [ServiceWarning ]
1534
+ warnings : list [ServiceWarning ]
1533
1535
1534
1536
def __init__ (
1535
1537
self ,
1536
1538
locales : Sequence [str ],
1537
1539
* ,
1538
- billing_address : Optional [Dict ] = None ,
1539
- billing_phone : Optional [Dict ] = None ,
1540
- credit_card : Optional [Dict ] = None ,
1541
- device : Optional [Dict ] = None ,
1542
- disposition : Optional [Dict ] = None ,
1543
- email : Optional [Dict ] = None ,
1540
+ billing_address : Optional [dict ] = None ,
1541
+ billing_phone : Optional [dict ] = None ,
1542
+ credit_card : Optional [dict ] = None ,
1543
+ device : Optional [dict ] = None ,
1544
+ disposition : Optional [dict ] = None ,
1545
+ email : Optional [dict ] = None ,
1544
1546
funds_remaining : float ,
1545
1547
# pylint:disable=redefined-builtin
1546
1548
id : str ,
1547
- ip_address : Optional [Dict ] = None ,
1549
+ ip_address : Optional [dict ] = None ,
1548
1550
queries_remaining : int ,
1549
1551
risk_score : float ,
1550
- shipping_address : Optional [Dict ] = None ,
1551
- shipping_phone : Optional [Dict ] = None ,
1552
- warnings : Optional [List [ Dict ]] = None ,
1552
+ shipping_address : Optional [dict ] = None ,
1553
+ shipping_phone : Optional [dict ] = None ,
1554
+ warnings : Optional [list [ dict ]] = None ,
1553
1555
** _ ,
1554
- ):
1556
+ ) -> None :
1555
1557
self .billing_address = BillingAddress (** (billing_address or {}))
1556
1558
self .billing_phone = Phone (** (billing_phone or {}))
1557
1559
self .credit_card = CreditCard (** (credit_card or {}))
@@ -1632,21 +1634,21 @@ class Score(_Serializable):
1632
1634
ip_address : ScoreIPAddress
1633
1635
queries_remaining : int
1634
1636
risk_score : float
1635
- warnings : List [ServiceWarning ]
1637
+ warnings : list [ServiceWarning ]
1636
1638
1637
1639
def __init__ (
1638
1640
self ,
1639
1641
* ,
1640
- disposition : Optional [Dict ] = None ,
1642
+ disposition : Optional [dict ] = None ,
1641
1643
funds_remaining : float ,
1642
1644
# pylint:disable=redefined-builtin
1643
1645
id : str ,
1644
- ip_address : Optional [Dict ] = None ,
1646
+ ip_address : Optional [dict ] = None ,
1645
1647
queries_remaining : int ,
1646
1648
risk_score : float ,
1647
- warnings : Optional [List [ Dict ]] = None ,
1649
+ warnings : Optional [list [ dict ]] = None ,
1648
1650
** _ ,
1649
- ):
1651
+ ) -> None :
1650
1652
self .disposition = Disposition (** (disposition or {}))
1651
1653
self .funds_remaining = funds_remaining
1652
1654
self .id = id
0 commit comments