Skip to content

Commit 4b0777a

Browse files
Added input validation
1 parent a007ff9 commit 4b0777a

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

todoist_api_python/api.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ def move_task(
485485
486486
Move a task to a different project, section, or parent task.
487487
488-
`project_id` takes predence, followed by `section_id` (which also updates `project_id`),
488+
`project_id` takes predence, followed by
489+
`section_id` (which also updates `project_id`),
489490
and then `parent_id` (which also updates `section_id` and `project_id`).
490491
491492
:param task_id: The ID of the task to move.
@@ -495,8 +496,18 @@ def move_task(
495496
:return: True if the task was moved successfully,
496497
False otherwise (possibly raise `HTTPError` instead).
497498
:raises requests.exceptions.HTTPError: If the API request fails.
498-
:raises ValueError: If neither `project_id`, `section_id`, nor `parent_id` is provided.
499+
:raises ValueError: When `task_id` is not provided.
500+
:raises ValueError: If neither `project_id`, `section_id`,
501+
nor `parent_id` is provided.
499502
"""
503+
if task_id is None:
504+
raise ValueError("`task_id` must be provided.")
505+
506+
if project_id is None and section_id is None and parent_id is None:
507+
raise ValueError(
508+
"Either `project_id`, `section_id`, or `parent_id` must be provided."
509+
)
510+
500511
data: dict[str, Any] = {}
501512
if project_id is not None:
502513
data["project_id"] = project_id

todoist_api_python/api_async.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,21 @@ async def move_task(
353353
Move a task.
354354
355355
Move a task to a different project, section, or parent task.
356-
Project_id takes precedence.
357-
Moving a task to a section or parent will update its project to match
358-
the project of the section or parent task.
359356
360-
:param task_id: The ID of the task to reopen.
361-
:param project_id: The ID of the project to add the task to.
362-
:param section_id: The ID of the section to add the task to.
363-
:param parent_id: The ID of the parent task.
357+
`project_id` takes predence, followed by
358+
`section_id` (which also updates `project_id`),
359+
and then `parent_id` (which also updates `section_id` and `project_id`).
360+
361+
:param task_id: The ID of the task to move.
362+
:param project_id: The ID of the project to move the task to.
363+
:param section_id: The ID of the section to move the task to.
364+
:param parent_id: The ID of the parent to move the task to.
364365
:return: True if the task was moved successfully,
365366
False otherwise (possibly raise `HTTPError` instead).
366367
:raises requests.exceptions.HTTPError: If the API request fails.
368+
:raises ValueError: When `task_id` is not provided.
369+
:raises ValueError: If neither `project_id`, `section_id`,
370+
nor `parent_id` is provided.
367371
"""
368372
return await run_async(
369373
lambda: self._api.move_task(

0 commit comments

Comments
 (0)