Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python sdk bug fixes #445

Merged
merged 3 commits into from
Dec 6, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

"""Base classes shared throughout models"""

import json

from pydantic import BaseModel

from open_gopro.util import pretty_print, scrub
Expand All @@ -12,7 +14,13 @@ class CustomBaseModel(BaseModel):
"""Additional functionality added to Pydantic BaseModel"""

def __hash__(self) -> int:
return hash((type(self),) + tuple(getattr(self, f) for f in self.__fields__.keys()))
h = hash((type(self),))
for field in self.__fields__.keys():
if isinstance(field, (dict, list)):
h += json.loads(field)
# Base case
h += hash(field)
return h

def __str__(self) -> str:
d = dict(self)
Expand Down
Loading