Skip to content

fix: call model_dump() on request bodies, not the v1 dict() - #78

Open
gsneto wants to merge 1 commit into
ldbumble:masterfrom
gsneto:fix/pydantic-v2-model-dump
Open

gsneto wants to merge 1 commit into
ldbumble:masterfrom
gsneto:fix/pydantic-v2-model-dump

Conversation

@gsneto

@gsneto gsneto commented Sep 26, 2026

Copy link
Copy Markdown

Closes #67.

What changed

taskuary/server.py called pydantic v1's body.dict() in ten places - every request that touched a body logged PydanticDeprecatedSince20, and the method is gone in v3. All ten are model_dump() now.

tests/test_no_pydantic_v1.py is the lock: it reads server.py and fails, naming the line, if a .dict() call comes back.

Why

pyproject.toml requires pydantic>=2. model_dump() is v2's name for the same call and returns the same shape, so no response changes.

How

rg -n "\.dict\(" taskuary/server.py -> ten hits: task create/update, split, calendar prep, ingest push, fixtures, and three settings-style updates. Each is .model_dump().

The guard test is verified against a reintroduced call, not just a green run: with body.dict() planted back at server.py:566 it fails and names the line.

Tests

python -m pytest tests/test_no_pydantic_v1.py -q
1 passed

python -m pytest -q
3 failed, 5362 passed, 8 skipped

The three failures are tests/test_browserview.py - RuntimeError: Event loop is closed in the websockets.serve teardown. They are not from this change: with the change stashed, the same file fails on master.

git stash push -u
python -m pytest tests/test_browserview.py -q
4 failed, 14 passed
git stash pop

Windows 11, Python 3.12.10, websockets 17.1.

We require pydantic>=2, but server.py still called the v1 accessor ten times, so every request that touched a body logged PydanticDeprecatedSince20 - and the method is gone in v3. All ten are model_dump() now.

test_no_pydantic_v1.py is the lock: it reads server.py and fails, naming the line, if a .dict() call comes back (issue ldbumble#67).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace pydantic v1 .dict() with .model_dump() in the API

1 participant