MAINT: Standardize deprecation calls and removed_in format#1817
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eprecation-calls # Conflicts: # pyrit/prompt_target/common/prompt_chat_target.py
The unit-test-diff-cover check failed because six newly-added print_deprecation_message(...) lines were not exercised by existing tests: - pyrit/output/scenario_result/base.py:38 (print_summary_async) - pyrit/output/scorer/base.py:68 (print_objective_scorer), :79 (print_harm_scorer) - pyrit/prompt_converter/persuasion_converter.py:132 (send_persuasion_prompt_async) - pyrit/prompt_converter/variation_converter.py:116 (send_variation_prompt_async) - pyrit/prompt_target/common/prompt_chat_target.py:53 (__init__) Add focused tests that invoke each shim, assert a DeprecationWarning is emitted, and verify the shim delegates to the replacement API. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jsong468
reviewed
May 27, 2026
jsong468
reviewed
May 27, 2026
jsong468
approved these changes
May 27, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…calls' into copilot/standardize-deprecation-calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related cleanup tasks across the PyRIT codebase, both guided by the "Deprecations" section of
.github/instructions/style-guide.instructions.md.Task 1 — convert
warnings.warn(..., DeprecationWarning, ...)→print_deprecation_message(15 sites across 9 files)The style guide mandates
pyrit.common.deprecation.print_deprecation_message(neverwarnings.warndirectly) for deprecations of public API. Converted:pyrit/datasets/seed_datasets/seed_dataset_provider.pypyrit/prompt_target/common/prompt_chat_target.pypyrit/prompt_target/azure_ml_chat_target.pypyrit/prompt_target/openai/openai_image_target.pypyrit/prompt_converter/azure_speech_audio_to_text_converter.pypyrit/prompt_converter/azure_speech_text_to_audio_converter.pypyrit/prompt_converter/persuasion_converter.pypyrit/prompt_converter/variation_converter.pypyrit/score/audio_transcript_scorer.pyEach conversion preserves the
removed_inversion the original message advertised. Unusedimport warningslines were dropped after conversion.Non-deprecation
warnings.warnsites (UserWarning,FutureWarning, suppression context managers) were intentionally left alone.Task 2 — strip the
vprefix fromremoved_in=(3 sites)Style-guide format is
"0.15.0", not"v0.15.0".pyrit/setup/initializers/__init__.pypyrit/setup/initializers/pyrit_initializer.pypyrit/prompt_target/hugging_face/hugging_face_endpoint_target.py(also converted fromwarnings.warnper Task 1's spirit)Task 3 (audit-driven) — normalize
removed_in="2.0"→"0.16.0"(12 sites)grepaudit surfaced 12print_deprecation_messagecalls inpyrit/output/that all setremoved_in="2.0"— a placeholder from the printer-refactor PR (#1732). Per the +2-minor-versions rule and the current0.14.0.dev0version, normalized all 12 to"0.16.0":pyrit/output/scorer/base.py(2)pyrit/output/scenario_result/pretty.py(1)pyrit/output/scenario_result/base.py(1)pyrit/output/attack_result/pretty.py(5)pyrit/output/attack_result/markdown.py(3)One intentional outlier was left alone:
pyrit/scenario/core/scenario_strategy.pyusesremoved_in="0.18.0"with an in-code comment explaining the extended window for Foundry callers.Test updates (4 files)
A few test assertions checked unique phrasing from the original
warnings.warnmessages that the helper format doesn't reproduce verbatim. Updated:tests/unit/datasets/test_seed_dataset_provider.py— 2 patternstests/unit/setup/test_pyrit_initializer.py— 2 patterns (droppedvfrom regex)tests/unit/prompt_target/target/test_image_target.py— 4 patterns (droppedv, adjusted quoting aroundstyle)tests/unit/prompt_target/target/test_normalize_async_integration.py— 1 pattern (message_normalizer is deprecated→message_normalizer+deprecatedchecked separately, to accommodate the helper's(param=...)suffix)tests/unit/prompt_converter/test_azure_speech_text_converter.py— 1 pattern (recognize_audio() does not support callable token providers→recognize_audio+deprecated)Verification
uv run pytest tests/unit -x -q→ 8049 passed, 118 skippeduv run pre-commit run --all-files→ all hooks pass (ruff format / ruff check / ty)grep "warnings\.warn.*DeprecationWarning" pyrit/→ zero hits outsidepyrit/common/deprecation.py(the helper itself)grep 'removed_in="v' pyrit/→ zero hitsgrep 'removed_in="2\.0"' pyrit/→ zero hits