What
ScenarioResult.to_dict() and ScenarioResult.from_dict(...) are marked for removal in 0.16.0, with the recommended replacements being ScenarioResult.model_dump(mode="json", by_alias=True) and ScenarioResult.model_validate(...). Internal PyRIT code still calls the deprecated forms, which emits a DeprecationWarning from pyrit/models/scenario_result.py on every GET /api/scenarios/runs/{id}/results REST call and every CLI scenario result print.
Where
Two production call sites and three docstring references:
pyrit/backend/routes/scenarios.py:225 calls result.to_dict() on the REST endpoint that serves scenario results.
pyrit/cli/_output.py:290 calls ScenarioResult.from_dict(result_dict) inside print_scenario_result_async.
- Docstrings in
pyrit/backend/routes/scenarios.py, pyrit/cli/_output.py, and pyrit/cli/api_client.py describe the REST payload as ScenarioResult.to_dict() shaped.
Why it is safe to migrate
The deprecated methods are thin wrappers that already delegate to the new Pydantic API. ScenarioResult.to_dict() returns self.model_dump(mode="json", by_alias=True) verbatim, and ScenarioResult.from_dict(data) returns cls.model_validate(data). Output dict shape is identical; only the deprecation warning goes away.
Proposed fix
Update the two call sites to use the Pydantic methods directly, refresh the three docstrings to describe the new payload spelling, and update the matching test fixtures that mock to_dict / from_dict. PR to follow.
What
ScenarioResult.to_dict()andScenarioResult.from_dict(...)are marked for removal in 0.16.0, with the recommended replacements beingScenarioResult.model_dump(mode="json", by_alias=True)andScenarioResult.model_validate(...). Internal PyRIT code still calls the deprecated forms, which emits aDeprecationWarningfrompyrit/models/scenario_result.pyon everyGET /api/scenarios/runs/{id}/resultsREST call and every CLI scenario result print.Where
Two production call sites and three docstring references:
pyrit/backend/routes/scenarios.py:225callsresult.to_dict()on the REST endpoint that serves scenario results.pyrit/cli/_output.py:290callsScenarioResult.from_dict(result_dict)insideprint_scenario_result_async.pyrit/backend/routes/scenarios.py,pyrit/cli/_output.py, andpyrit/cli/api_client.pydescribe the REST payload asScenarioResult.to_dict()shaped.Why it is safe to migrate
The deprecated methods are thin wrappers that already delegate to the new Pydantic API.
ScenarioResult.to_dict()returnsself.model_dump(mode="json", by_alias=True)verbatim, andScenarioResult.from_dict(data)returnscls.model_validate(data). Output dict shape is identical; only the deprecation warning goes away.Proposed fix
Update the two call sites to use the Pydantic methods directly, refresh the three docstrings to describe the new payload spelling, and update the matching test fixtures that mock
to_dict/from_dict. PR to follow.