Skip to content

Commit d49bff0

Browse files
committed
Fix error if data in response is None
1 parent ba29d5e commit d49bff0

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "toggl_python"
3-
version = "0.2.4"
3+
version = "0.2.5"
44
description = "Python wraper for Toggl API."
55
authors = ["Ivlev Denis <[email protected]>"]
66
readme = "README.md"

toggl_python/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.2.4"
1+
__version__ = "0.2.5"
22

33
from .auth import BasicAuth, TokenAuth # noqa: F401
44
from .entities import Dashboard # noqa: F401

toggl_python/repository.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ def _retrieve(self, _url, entity_class, data_key: str = "data", **kwargs):
9494

9595
response = self.get(_url, params=params)
9696
data = response.json()
97-
data_key = data_key or self.DATA_CONTAINER.get('retrieve', None)
97+
data_key = data_key or self.DATA_CONTAINER.get("retrieve", None)
9898
if data_key:
9999
data = data[data_key]
100-
return entity_class(**data)
100+
if data:
101+
return entity_class(**data)
101102

102103
def retrieve(self, id: int = None, **kwargs):
103104
full_url = self.BASE_URL.join(self.DETAIL_URL.format(id=id))
@@ -109,10 +110,11 @@ def _list(self, _url, entity_class, data_key: str = None, **kwargs):
109110

110111
response = self.get(_url, params=params)
111112
data = response.json()
112-
data_key = data_key or self.DATA_CONTAINER.get('list', None)
113+
data_key = data_key or self.DATA_CONTAINER.get("list", None)
113114
if data_key:
114115
data = data[data_key]
115-
return [entity_class(**entity) for entity in data]
116+
if data:
117+
return [entity_class(**entity) for entity in data]
116118

117119
def list(self, **kwargs):
118120
if "list" in self.EXCLUDED_METHODS:

0 commit comments

Comments
 (0)