Skip to content

Commit

Permalink
Remove deprecate attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwald committed Jan 17, 2025
1 parent fc4a5f9 commit 6bd16e6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 38 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ History
classes are no longer immutable. For most users, these differences should
not impact their integration.
* BREAKING CHANGE: Model attributes that were formerly tuples are now lists.
* BREAKING CHANGE: The deprecated `is_high_risk` attribute on
`resp.ip_address.country` has been removed.
* IMPORTANT: Python 3.9 or greater is required. If you are using an older
version, please use an earlier release.
* Added ``to_dict`` methods to the model classes. These return a dict version
Expand Down
30 changes: 0 additions & 30 deletions minfraud/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,34 +116,6 @@ def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)


class GeoIP2Country(geoip2.records.Country):
"""Country information for the IP address.
In addition to the attributes provided by ``geoip2.records.Country``,
this class provides:
.. attribute:: is_high_risk
This is true if the IP country is high risk.
:type: bool | None
.. deprecated:: 1.8.0
Deprecated effective August 29, 2019.
Parent:
"""

__doc__ += geoip2.records.Country.__doc__ # type: ignore

is_high_risk: bool

def __init__(self, *args, **kwargs) -> None:
self.is_high_risk = kwargs.get("is_high_risk", False)
super().__init__(*args, **kwargs)


class IPAddress(geoip2.models.Insights):
"""Model for minFraud and GeoIP2 data about the IP address.
Expand Down Expand Up @@ -222,7 +194,6 @@ class IPAddress(geoip2.models.Insights):
"""

country: GeoIP2Country
location: GeoIP2Location
risk: Optional[float]
risk_reasons: List[IPRiskReason]
Expand All @@ -248,7 +219,6 @@ def __init__(
kwargs["risk_reasons"] = risk_reasons

super().__init__(kwargs, locales=list(locales or []))
self.country = GeoIP2Country(locales, **(country or {}))
self.location = GeoIP2Location(**(location or {}))
self.risk = risk
self.risk_reasons = [IPRiskReason(**x) for x in risk_reasons or []]
Expand Down
8 changes: 0 additions & 8 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ def test_email_domain(self):

self.assertEqual(first_seen, domain.first_seen)

def test_geoip2_country(self):
country = GeoIP2Country(is_high_risk=True, iso_code="US")
self.assertEqual(True, country.is_high_risk)
self.assertEqual("US", country.iso_code)

def test_geoip2_location(self):
time = "2015-04-19T12:59:23-01:00"
location = GeoIP2Location(local_time=time, latitude=5)
Expand All @@ -124,7 +119,6 @@ def test_ip_address(self):
address = IPAddress(
["en"],
country={
"is_high_risk": True,
"is_in_european_union": True,
},
location={
Expand Down Expand Up @@ -156,7 +150,6 @@ def test_ip_address(self):
)

self.assertEqual(time, address.location.local_time)
self.assertEqual(True, address.country.is_high_risk)
self.assertEqual(True, address.country.is_in_european_union)
self.assertEqual(99, address.risk)
self.assertEqual(True, address.traits.is_anonymous)
Expand All @@ -169,7 +162,6 @@ def test_ip_address(self):
self.assertEqual(True, address.traits.is_tor_exit_node)
self.assertEqual("310", address.traits.mobile_country_code)
self.assertEqual("004", address.traits.mobile_network_code)
self.assertEqual(True, address.country.is_high_risk)

self.assertEqual("ANONYMOUS_IP", address.risk_reasons[0].code)
self.assertEqual(
Expand Down

0 comments on commit 6bd16e6

Please sign in to comment.