From 2e38b73c48c7da9e96cab6e5e540b7b6f017fae5 Mon Sep 17 00:00:00 2001 From: Amir Date: Thu, 29 Oct 2026 08:29:26 +0100 Subject: [PATCH] fix: load projects with a view style this version doesn't know `Project.view_style` was a strict `Literal["list", "board", "calendar"]`, so a project with any other style, like a newly added layout, failed to load, and with it the whole page of projects. It's now read as a string. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 ++++ tests/test_models.py | 9 +++++++++ todoist_api_python/models.py | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c552438..c6c5079 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for Python 3.9 (EOL). +### Fixed + +- Loading a project no longer fails when its `view_style` is one this version doesn't know yet, like a newly added layout. Its value is kept as is. + ### Changed - **Breaking**: Replaced the `httpx` runtime dependency with `httpx2`; caller-supplied clients and caught HTTP exceptions must now come from `httpx2`. diff --git a/tests/test_models.py b/tests/test_models.py index 3ec24ba..5721226 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -76,6 +76,15 @@ def test_project_from_dict() -> None: assert project.updated_at == parse_datetime(str(sample_data["updated_at"])) +def test_project_with_unknown_view_style() -> None: + sample_data = dict(DEFAULT_PROJECT_RESPONSE) + sample_data["view_style"] = "table" + + project = Project.from_dict(sample_data) + + assert project.view_style == "table" + + def test_project_url() -> None: inbox = Project.from_dict(dict(DEFAULT_PROJECT_RESPONSE)) assert inbox.url == "https://app.todoist.com/app/inbox" diff --git a/todoist_api_python/models.py b/todoist_api_python/models.py index 55364f7..e059a8a 100644 --- a/todoist_api_python/models.py +++ b/todoist_api_python/models.py @@ -35,7 +35,8 @@ class _(JSONPyWizard.Meta): # noqa:N801 is_favorite: bool is_archived: bool can_assign_tasks: bool - view_style: ViewStyle + # Any string, so a style this version doesn't know yet doesn't fail loading + view_style: str created_at: ApiDate updated_at: ApiDate