Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `TodoistAPIAsync` now performs true async HTTP I/O with `httpx2.AsyncClient`.
- Support for Python 3.14.
- `add_project` and `update_project` accept the `table` view style.

### Removed

Expand Down
12 changes: 7 additions & 5 deletions tests/test_api_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,41 +160,43 @@ async def test_add_project_minimal(


@pytest.mark.asyncio
@pytest.mark.parametrize("view_style", ["board", "table"])
async def test_add_project_full(
todoist_api: TodoistAPI,
todoist_api_async: TodoistAPIAsync,
respx_mock: respx.MockRouter,
default_project_response: dict[str, Any],
default_project: Project,
view_style: str,
) -> None:
project_name = "A Project"
args: dict[str, Any] = {
"description": "A project description",
"parent_id": "3Ty8VQXxpwv28PK3",
"color": "red",
"is_favorite": True,
"view_style": "board",
"view_style": view_style,
}
project_response = default_project_response | {"view_style": view_style}

mock_route(
respx_mock,
method="POST",
url=f"{DEFAULT_API_URL}/projects",
request_headers=api_headers(),
request_json={"name": project_name} | args,
response_json=default_project_response,
response_json=project_response,
response_status=200,
)

new_project = todoist_api.add_project(name=project_name, **args)

assert len(respx_mock.calls) == 1
assert new_project == default_project
assert new_project == Project.from_dict(project_response)

new_project = await todoist_api_async.add_project(name=project_name, **args)

assert len(respx_mock.calls) == 2
assert new_project == default_project
assert new_project == Project.from_dict(project_response)


@pytest.mark.asyncio
Expand Down
4 changes: 2 additions & 2 deletions todoist_api_python/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ def add_project(
:param parent_id: The ID of the parent project. Set to null for root projects.
:param color: The color of the project icon.
:param is_favorite: Whether the project is a favorite.
:param view_style: A string value (either 'list' or 'board', default is 'list').
:param view_style: 'list', 'board', 'calendar' or 'table' (default is 'list').
:return: The newly created project.
:raises httpx2.HTTPStatusError: If the API request fails.
:raises TypeError: If the API response is not a valid Project dictionary.
Expand Down Expand Up @@ -788,7 +788,7 @@ def update_project(
:param description: Description for the project (up to 1024 characters).
:param color: The color of the project icon.
:param is_favorite: Whether the project is a favorite.
:param view_style: A string value (either 'list' or 'board').
:param view_style: 'list', 'board', 'calendar' or 'table'.
:param order: Position of the project among projects with the same parent.
:param collapsed: Whether the project's sub-projects are collapsed.
:return: the updated Project.
Expand Down
4 changes: 2 additions & 2 deletions todoist_api_python/api_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ async def add_project(
:param parent_id: The ID of the parent project. Set to null for root projects.
:param color: The color of the project icon.
:param is_favorite: Whether the project is a favorite.
:param view_style: A string value (either 'list' or 'board', default is 'list').
:param view_style: 'list', 'board', 'calendar' or 'table' (default is 'list').
:return: The newly created project.
:raises httpx2.HTTPStatusError: If the API request fails.
:raises TypeError: If the API response is not a valid Project dictionary.
Expand Down Expand Up @@ -808,7 +808,7 @@ async def update_project(
:param description: Description for the project (up to 1024 characters).
:param color: The color of the project icon.
:param is_favorite: Whether the project is a favorite.
:param view_style: A string value (either 'list' or 'board').
:param view_style: 'list', 'board', 'calendar' or 'table'.
:param order: Position of the project among projects with the same parent.
:param collapsed: Whether the project's sub-projects are collapsed.
:return: the updated Project.
Expand Down
2 changes: 1 addition & 1 deletion todoist_api_python/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from todoist_api_python._core.endpoints import INBOX_URL, get_project_url, get_task_url

ViewStyle = Literal["list", "board", "calendar"]
ViewStyle = Literal["list", "board", "calendar", "table"]
DurationUnit = Literal["minute", "day"]
ReminderType = Literal["relative", "absolute"]
ReminderService = Literal["email", "push"]
Expand Down
2 changes: 1 addition & 1 deletion todoist_api_python/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
]
ViewStyle = Annotated[
str,
Predicate(lambda value: value in ("list", "board", "calendar")),
Predicate(lambda value: value in ("list", "board", "calendar", "table")),
]

__all__ = ["ColorString", "LanguageCode", "ViewStyle"]
Loading