You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optional fields in the "from_dict" constructor for each object type use .get such that, if the field is missing, it's populated with None. The section_id on class Task does not do this, even though it should default to None.
It seems that the Todoist API always returns a null section_id so this doesn't matter in practice, but if you're mocking the API (for testing) it's a minor inconvenience.
Expected behaviour
If a Task is constructed from a dict that does not have a section_id, it should set section_id to None.
Is reproducible
Yes
To reproduce
# this raises a KeyError due to a missing section_idtask=Task.from_dict(
{
"assigner_id": "abc123",
"assignee_id": "abc123",
"comment_count": 0,
"is_completed": False,
"content": "def234",
"created_at": "2023-04-24T00:00:00.0000Z",
"creator_id": "abc123",
"description": "",
"labels": [],
"order": 1,
"priority": 1,
"url": "https://github.com/",
}
)
Steps taken to try to reproduce
N/A, the fix is easy, you can simply replace section_id=obj["section_id"], with section_id=obj.get("section_id") (or, as a user, just supply a null section_id, of course)
Bug description
Optional fields in the "from_dict" constructor for each object type use
.get
such that, if the field is missing, it's populated withNone
. Thesection_id
onclass Task
does not do this, even though it should default toNone
.It seems that the Todoist API always returns a null
section_id
so this doesn't matter in practice, but if you're mocking the API (for testing) it's a minor inconvenience.Expected behaviour
If a Task is constructed from a
dict
that does not have asection_id
, it should setsection_id
toNone
.Is reproducible
Yes
To reproduce
Steps taken to try to reproduce
N/A, the fix is easy, you can simply replace
section_id=obj["section_id"],
withsection_id=obj.get("section_id")
(or, as a user, just supply a nullsection_id
, of course)Screenshots
N/A
Version information:
Additional information
See https://github.com/Doist/todoist-api-python/blob/main/todoist_api_python/models.py#L158
The text was updated successfully, but these errors were encountered: