Skip to content

Commit

Permalink
Fix Pydantic warning on data_test run (openai#1445)
Browse files Browse the repository at this point in the history
This PR fixes a warning from Pydantic when running the JSON dumps test
in `data_test.py`:

```
evals/data_test.py::test_jsondumps
evals/data_test.py::test_jsondumps
evals/data_test.py::test_jsondumps
  /evals/evals/data.py:191: PydanticDeprecatedSince20: The `json` method is deprecated; use `model_dump_json` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/
    for k, v in json.loads(o.json()).items()

evals/data_test.py::test_jsondumps
evals/data_test.py::test_jsondumps
evals/data_test.py::test_jsondumps
  /evals/lib/python3.9/site-packages/pydantic/main.py:1005: PydanticDeprecatedSince20: The `json` method is deprecated; use `model_dump_json` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/
    warnings.warn('The `json` method is deprecated; use `model_dump_json` instead.', DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
```
  • Loading branch information
inwaves authored Dec 21, 2023
1 parent 23ae8ab commit dd38662
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion evals/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def _to_py_types(o: Any, exclude_keys: List[Text]) -> Any:
if isinstance(o, pydantic.BaseModel):
return {
k: _to_py_types(v, exclude_keys=exclude_keys)
for k, v in json.loads(o.json()).items()
for k, v in json.loads(o.model_dump_json()).items()
if k not in exclude_keys
}

Expand Down

0 comments on commit dd38662

Please sign in to comment.