From 41344d518a4f2c6313cca30f5ed08400876263b2 Mon Sep 17 00:00:00 2001 From: Joseph Chiocchi Date: Thu, 10 Nov 2022 04:32:46 -0600 Subject: [PATCH 1/3] patch++0.0.9 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e6e052b..7ff8b9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ build-backend = "hatchling.build" [project] name = "dexie.py" -version = "0.0.8" +version = "0.0.9" authors = [ { name="Joseph Chiocchi", email="joe@yolk.cc" }, ] From efa71f75c8355bb8c66aa755d461123f4248353a Mon Sep 17 00:00:00 2001 From: Joseph Chiocchi Date: Thu, 10 Nov 2022 04:37:52 -0600 Subject: [PATCH 2/3] cleanup --- dexie.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dexie.py b/dexie.py index 8a26403..345888e 100644 --- a/dexie.py +++ b/dexie.py @@ -212,7 +212,7 @@ def __init__(self, model, model_cls): self._model_cls = model_cls def convert(self, value): - if hasattr(value, "json"): + if hasattr(value, "json") and callable(value.get("json")): data = value.json() else: # this is a safe fallback that should be forwards compatible to @@ -221,14 +221,15 @@ def convert(self, value): if data.get("success"): if self._model is not None: - # sometimes we do need to inject more data like HistoricalTrades - # which doesn't just have a single key with all the data - # we could detect it here, but we can maybe also pass the req_def + # collections are plural if self._model.endswith("s"): datas = data[self._model] return [self._model_cls(**datum) for datum in datas] return self._model_cls(**data[self._model]) + # sometimes we do need to inject more data like HistoricalTrades + # which doesn't just have a single key with all the data + # we could detect it here, but we can maybe also pass the req_def # we wrap our data with our model_cls # remove the response success key, which we no longer need model_data = {k: data[k] for k in data if k != "success"} From ca3d8323223eb1a35c0938c29ecc14b90de7db15 Mon Sep 17 00:00:00 2001 From: Joseph Chiocchi Date: Thu, 10 Nov 2022 04:42:01 -0600 Subject: [PATCH 3/3] cleanup --- dexie.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dexie.py b/dexie.py index 345888e..541c556 100644 --- a/dexie.py +++ b/dexie.py @@ -229,10 +229,9 @@ def convert(self, value): # sometimes we do need to inject more data like HistoricalTrades # which doesn't just have a single key with all the data - # we could detect it here, but we can maybe also pass the req_def - # we wrap our data with our model_cls # remove the response success key, which we no longer need model_data = {k: data[k] for k in data if k != "success"} + # we wrap our data with our model_cls return self._model_cls(**model_data) return data