Skip to content

Commit 547b6de

Browse files
committed
Add deadline support
Deadline was already supported when creating and updating tasks since the migration to the Todoist API v1. It is now also returned on the Task object (and `meta`, when present). Closes #165
1 parent 0c215c6 commit 547b6de

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tests/data/test_defaults.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class PaginatedItems(TypedDict):
2626
"is_recurring": True,
2727
}
2828

29+
DEFAULT_DEADLINE_RESPONSE = {
30+
"date": "2016-09-01",
31+
"lang": "en",
32+
}
33+
2934
DEFAULT_DURATION_RESPONSE = {
3035
"amount": 60,
3136
"unit": "minute",
@@ -37,6 +42,7 @@ class PaginatedItems(TypedDict):
3742
"assignee": [None, None],
3843
"labels": {},
3944
"due": None,
45+
"deadline": None,
4046
}
4147

4248
DEFAULT_PROJECT_RESPONSE = {
@@ -88,6 +94,7 @@ class PaginatedItems(TypedDict):
8894
"labels": [],
8995
"priority": 1,
9096
"due": DEFAULT_DUE_RESPONSE,
97+
"deadline": DEFAULT_DEADLINE_RESPONSE,
9198
"duration": DEFAULT_DURATION_RESPONSE,
9299
"collapsed": False,
93100
"child_order": 3,

todoist_api_python/models.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ class _(JSONPyWizard.Meta): # noqa:N801
7474
timezone: str | None = None
7575

7676

77+
@dataclass
78+
class Deadline(JSONPyWizard):
79+
class _(JSONPyWizard.Meta): # noqa:N801
80+
v1 = True
81+
82+
date: ApiDue
83+
lang: str = "en"
84+
85+
7786
@dataclass
7887
class Meta(JSONPyWizard):
7988
class _(JSONPyWizard.Meta): # noqa:N801
@@ -84,6 +93,7 @@ class _(JSONPyWizard.Meta): # noqa:N801
8493
assignee: tuple[str, str]
8594
labels: dict[int, str]
8695
due: Due | None
96+
deadline: Deadline | None
8797

8898

8999
@dataclass
@@ -100,6 +110,7 @@ class _(JSONPyWizard.Meta): # noqa:N801
100110
labels: list[str] | None
101111
priority: int
102112
due: Due | None
113+
deadline: Deadline | None
103114
duration: Duration | None
104115
is_collapsed: Annotated[bool, Alias(load=("collapsed", "is_collapsed"))]
105116
order: Annotated[int, Alias(load=("child_order", "order"))]

0 commit comments

Comments
 (0)