Skip to content

Commit

Permalink
Chore: Make release 1.2.18
Browse files Browse the repository at this point in the history
  • Loading branch information
martinroberson authored and tialuo committed Jan 22, 2025
1 parent 6effc3c commit 8231613
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions gs_quant/api/gs/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,15 @@ def set_api_request_cache(cls, cache: ApiRequestCache):

@classmethod
def _construct_cache_key(cls, url, **kwargs) -> tuple:
def fallback_encoder(v) -> str:
if isinstance(v, dt.date):
return v.isoformat()

def serialize_value(v):
if any(isinstance(v, class_) for class_ in {MDAPIDataQuery, DataQuery}):
return v.to_json(sort_keys=True)
elif isinstance(v, dt.date):
return v.isoformat()
return v
return v.to_json(sort_keys=True, default=fallback_encoder)
encoded_v = fallback_encoder(v)
return encoded_v or v

json_kwargs = {
k: serialize_value(v)
Expand Down

0 comments on commit 8231613

Please sign in to comment.