From fe2197171e374572d9c8cd196545f8698fea573c Mon Sep 17 00:00:00 2001 From: DRVR1 <68394559+DRVR1@users.noreply.github.com> Date: Tue, 20 Feb 2024 23:00:20 -0300 Subject: [PATCH 1/2] Enable hashing by .pk to convert lists into sets --- instagrapi/types.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/instagrapi/types.py b/instagrapi/types.py index 123eb9a7..e8815f2d 100644 --- a/instagrapi/types.py +++ b/instagrapi/types.py @@ -31,6 +31,8 @@ class Resource(TypesBaseModel): class User(TypesBaseModel): + def __hash__(self): + return hash(self.pk) pk: str username: str full_name: str @@ -68,6 +70,8 @@ class User(TypesBaseModel): class Account(TypesBaseModel): + def __hash__(self): + return hash(self.pk) pk: str username: str full_name: str @@ -86,6 +90,8 @@ class Account(TypesBaseModel): class UserShort(TypesBaseModel): + def __hash__(self): + return hash(self.pk) pk: str username: Optional[str] = None full_name: Optional[str] = "" From 1192fadc9e0f18ad4b15bc2dfe4355161451e4af Mon Sep 17 00:00:00 2001 From: DRVR1 <68394559+DRVR1@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:38:01 -0300 Subject: [PATCH 2/2] Fixed set --- instagrapi/types.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/instagrapi/types.py b/instagrapi/types.py index e8815f2d..1f1cac32 100644 --- a/instagrapi/types.py +++ b/instagrapi/types.py @@ -31,8 +31,6 @@ class Resource(TypesBaseModel): class User(TypesBaseModel): - def __hash__(self): - return hash(self.pk) pk: str username: str full_name: str @@ -70,8 +68,6 @@ def __hash__(self): class Account(TypesBaseModel): - def __hash__(self): - return hash(self.pk) pk: str username: str full_name: str @@ -92,6 +88,10 @@ def __hash__(self): class UserShort(TypesBaseModel): def __hash__(self): return hash(self.pk) + def __eq__(self, other): + if isinstance(other, UserShort): + return self.pk == other.pk + return NotImplemented pk: str username: Optional[str] = None full_name: Optional[str] = ""