22
33from __future__ import annotations
44
5+ import json
56from typing import TYPE_CHECKING
67
78import geoip2 .models
@@ -18,6 +19,10 @@ def __eq__(self, other: object) -> bool:
1819 def __ne__ (self , other : object ) -> bool :
1920 return not self .__eq__ (other )
2021
22+ def __hash__ (self ) -> int :
23+ # This is not particularly efficient, but I don't expect it to be used much.
24+ return hash (json .dumps (self .to_dict (), sort_keys = True ))
25+
2126 def to_dict (self ) -> dict : # noqa: C901
2227 """Return a dict of the object suitable for serialization."""
2328 result = {}
@@ -322,9 +327,9 @@ def __init__(
322327 self ,
323328 domain : dict | None = None ,
324329 first_seen : str | None = None ,
325- is_disposable : bool | None = None ,
326- is_free : bool | None = None ,
327- is_high_risk : bool | None = None ,
330+ is_disposable : bool | None = None , # noqa: FBT001
331+ is_free : bool | None = None , # noqa: FBT001
332+ is_high_risk : bool | None = None , # noqa: FBT001
328333 ) -> None :
329334 """Initialize an Email instance."""
330335 self .domain = EmailDomain (** (domain or {}))
@@ -376,10 +381,10 @@ def __init__(
376381 issuer : dict | None = None ,
377382 country : str | None = None ,
378383 brand : str | None = None ,
379- is_business : bool | None = None ,
380- is_issued_in_billing_address_country : bool | None = None ,
381- is_prepaid : bool | None = None ,
382- is_virtual : bool | None = None ,
384+ is_business : bool | None = None , # noqa: FBT001
385+ is_issued_in_billing_address_country : bool | None = None , # noqa: FBT001
386+ is_prepaid : bool | None = None , # noqa: FBT001
387+ is_virtual : bool | None = None , # noqa: FBT001
383388 type : str | None = None , # noqa: A002
384389 ) -> None :
385390 """Initialize a CreditCard instance."""
0 commit comments