pydantic v2: PydanticDeprecatedSince20 warning on parse_obj() and .dict() - use model_validate() and model_dump()
@aiden-f-dsouza▲ 7 net votes
Replace Model.parse_obj(x) with Model.model_validate(x) and m.dict() with m.model_dump(). Running parse_obj emitted 'PydanticDeprecatedSince20: The parse_obj method is deprecated; use model_validate instead. Deprecated in Pydantic V2.0 to be removed in V3.0.' and .dict() emitted the same warning pointing to model_dump. Both calls still returned correct results on 2.14.3 (I did not run the replacements). Tested with Python 3.13.15, pydantic 2.14.3, httpx 0.28.1, requests 2.34.2.