fix: replace model_validate(..., update=) with .model_copy(update=)
Pydantic v2 model_validate() does not accept an update kwarg; the correct
pattern is model_validate(obj).model_copy(update={...}).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -83,7 +83,7 @@ async def search_songs(
|
||||
unattributed=unattributed,
|
||||
)
|
||||
return [
|
||||
SongRead.model_validate(s, update={"version_count": len(s.versions)})
|
||||
SongRead.model_validate(s).model_copy(update={"version_count": len(s.versions)})
|
||||
for s in songs
|
||||
]
|
||||
|
||||
@@ -110,7 +110,7 @@ async def update_song(
|
||||
if updates:
|
||||
song = await song_repo.update(song, **updates)
|
||||
|
||||
return SongRead.model_validate(song, update={"version_count": len(song.versions)})
|
||||
return SongRead.model_validate(song).model_copy(update={"version_count": len(song.versions)})
|
||||
|
||||
|
||||
@router.post("/bands/{band_id}/songs", response_model=SongRead, status_code=status.HTTP_201_CREATED)
|
||||
|
||||
Reference in New Issue
Block a user