Skip to content

Commit bd27b76

Browse files
behnam-oBehnam Ousat
andauthored
FIX add back print_conversation_async with deprecation warning (#1781)
Co-authored-by: Behnam Ousat <behnamousat@microsoft.com>
1 parent 75e2314 commit bd27b76

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

pyrit/output/attack_result/pretty.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ async def _render_conversation_async(
158158
include_reasoning_trace=include_reasoning_trace,
159159
)
160160

161+
async def print_conversation_async(
162+
self, result: AttackResult, *, include_scores: bool = False, include_reasoning_trace: bool = False
163+
) -> None:
164+
"""Use ``write_async`` instead. This method is deprecated."""
165+
print_deprecation_message(old_item="print_conversation_async", new_item="write_async", removed_in="2.0")
166+
content = await self._render_conversation_async(
167+
result, include_scores=include_scores, include_reasoning_trace=include_reasoning_trace
168+
)
169+
await self._write_async(content)
170+
161171
async def output_conversation_async(
162172
self, result: AttackResult, *, include_scores: bool = False, include_reasoning_trace: bool = False
163173
) -> None:

tests/unit/output/attack_result/test_pretty.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ async def test_print_result_async_emits_deprecation_warning_and_still_writes(pri
339339
assert "ATTACK RESULT" in capsys.readouterr().out
340340

341341

342+
async def test_print_conversation_async_emits_deprecation_warning(printer, attack_result, capsys):
343+
with pytest.warns(DeprecationWarning, match="print_conversation_async"):
344+
await printer.print_conversation_async(attack_result)
345+
assert "No conversation found" in capsys.readouterr().out
346+
347+
342348
async def test_output_conversation_async_emits_deprecation_warning(printer, attack_result, capsys):
343349
with pytest.warns(DeprecationWarning, match="output_conversation_async"):
344350
await printer.output_conversation_async(attack_result)

0 commit comments

Comments
 (0)