diff --git a/minfraud/models.py b/minfraud/models.py index 29477ac..3d83cb2 100644 --- a/minfraud/models.py +++ b/minfraud/models.py @@ -12,10 +12,15 @@ import geoip2.models import geoip2.records -from geoip2.mixins import SimpleEquality -class _Serializable(SimpleEquality): +class _Serializable: + def __eq__(self, other: object) -> bool: + return isinstance(other, self.__class__) and self.to_dict() == other.to_dict() + + def __ne__(self, other: object) -> bool: + return not self.__eq__(other) + def to_dict(self) -> dict: """Returns a dict of the object suitable for serialization.""" result = {} @@ -23,10 +28,6 @@ def to_dict(self) -> dict: if hasattr(value, "to_dict") and callable(value.to_dict): if d := value.to_dict(): result[key] = d - elif hasattr(value, "raw"): - # geoip2 uses "raw" for historical reasons - if d := value.raw: - result[key] = d elif isinstance(value, list): ls = [] for e in value: @@ -221,7 +222,7 @@ def __init__( if risk_reasons is not None: kwargs["risk_reasons"] = risk_reasons - super().__init__(kwargs, locales=list(locales or [])) + super().__init__(locales, **kwargs) self.location = GeoIP2Location(**(location or {})) self.risk = risk self.risk_reasons = [IPRiskReason(**x) for x in risk_reasons or []] diff --git a/pyproject.toml b/pyproject.toml index 949472d..aec807b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ authors = [ dependencies = [ "aiohttp>=3.6.2,<4.0.0", "email_validator>=2.0.0,<3.0.0", - "geoip2>=4.8.0,<5.0.0", + "geoip2>=5.0.1,<6.0.0", "requests>=2.24.0,<3.0.0", "voluptuous", ]