Skip to content

Commit b0a1370

Browse files
authored
Merge pull request #269 from Doist/amix/tolerate-unknown-view-style
fix: load projects with unknown view styles
2 parents e64e3be + cd74db1 commit b0a1370

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- **Breaking**: `update_section` now accepts only keyword arguments after `section_id`; any one of `name`, `order`, or `collapsed` can be updated in the same call.
2828
- **Breaking**: `add_label` and `update_label` now accept `order` instead of `item_order` for label ordering. (#247)
2929

30+
### Fixed
31+
32+
- Loading a project no longer fails when its `view_style` is one the SDK doesn't know yet; `Project.view_style` is now typed as `str` and keeps the value as sent.
33+
3034
## [3.2.1] - 2026-01-22
3135

3236
### Fixed

‎tests/test_models.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import pytest
4+
35
from tests.data.test_defaults import (
46
DEFAULT_ATTACHMENT_RESPONSE,
57
DEFAULT_COLLABORATOR_RESPONSE,
@@ -76,6 +78,16 @@ def test_project_from_dict() -> None:
7678
assert project.updated_at == parse_datetime(str(sample_data["updated_at"]))
7779

7880

81+
@pytest.mark.parametrize("view_style", ["table", "some_future_view_style"])
82+
def test_project_from_dict_with_unknown_view_style(view_style: str) -> None:
83+
sample_data = dict(DEFAULT_PROJECT_RESPONSE)
84+
sample_data["view_style"] = view_style
85+
86+
project = Project.from_dict(sample_data)
87+
88+
assert project.view_style == view_style
89+
90+
7991
def test_project_url() -> None:
8092
inbox = Project.from_dict(dict(DEFAULT_PROJECT_RESPONSE))
8193
assert inbox.url == "https://app.todoist.com/app/inbox"

‎todoist_api_python/models.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class _(JSONPyWizard.Meta): # noqa:N801
3535
is_favorite: bool
3636
is_archived: bool
3737
can_assign_tasks: bool
38-
view_style: ViewStyle
38+
# Not `ViewStyle`: the API can add view styles, which a Literal would fail to load.
39+
view_style: str
3940
created_at: ApiDate
4041
updated_at: ApiDate
4142

0 commit comments

Comments
 (0)