Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions geoip2/_internal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Internal utilities."""

import json
from abc import ABCMeta


Expand All @@ -12,6 +13,10 @@ def __eq__(self, other: object) -> bool:
def __ne__(self, other: object) -> bool:
return not self.__eq__(other)

def __hash__(self) -> int:
# This is not particularly efficient, but I don't expect it to be used much.
return hash(json.dumps(self.to_dict(), sort_keys=True))

def to_dict(self) -> dict: # noqa: C901, PLR0912
"""Return a dict of the object suitable for serialization."""
result = {}
Expand Down
Loading
Loading