MAINT: Migrate AddImage/AddTextImage converter deprecations to print_deprecation_message#1875
Merged
romanlutz merged 5 commits intoJun 2, 2026
Conversation
…deprecation_message The PyRIT style guide (.github/instructions/style-guide.instructions.md, Deprecations section) requires all deprecations to go through pyrit.common.deprecation.print_deprecation_message — never raw warnings.warn — so message format and DeprecationWarning filtering stay consistent across the codebase. Three call sites in the prompt_converter package bypassed the helper by emitting FutureWarning directly. They are all positional/legacy-kwarg migrations introduced in commit bde0ed1 (PR microsoft#1591) on 2026-04-22, during the 0.14.0.dev0 cycle (i.e. after v0.13.0 was tagged). The originally announced removal version is 0.15.0, which has not yet shipped to users, so we preserve removed_in="0.15.0" on all three — this migrates the *mechanism* without resetting the deprecation clock. Migrated sites: - pyrit/prompt_converter/add_text_image_converter.py:66 (positional text_to_add → keyword) - pyrit/prompt_converter/add_image_text_converter.py:86 (positional img_to_add → keyword) - pyrit/prompt_converter/add_image_text_converter.py:99 (x_pos/y_pos → bounding_box) The warning class changes FutureWarning → DeprecationWarning as a side effect of using the helper, so the three corresponding pytest.warns assertions and the warnings.simplefilter("error", ...) check in tests/unit/prompt_converter/test_add_image_text_converter.py were updated to match. Verified separately: the two warnings.warn(..., UserWarning, ...) calls in pyrit/prompt_target/hugging_face/{hugging_face_endpoint_target, hugging_face_chat_target}.py are legitimate user-misconfiguration warnings about sampling parameters (not deprecations) and were left untouched, as was the ExperimentalWarning in pyrit/auxiliary_attacks/__init__.py. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eprecation-helper-migration # Conflicts: # pyrit/prompt_converter/add_image_text_converter.py # pyrit/prompt_converter/add_text_image_converter.py
adrian-gavrila
approved these changes
Jun 1, 2026
jbolor21
approved these changes
Jun 1, 2026
ValbuenaVC
reviewed
Jun 1, 2026
…eprecation-helper-migration
Adds three tests mirroring AddImageTextConverter's positional-arg coverage: - positional text_to_add emits DeprecationWarning and still works - positional + keyword raises TypeError - 2+ positional args raises TypeError Lifts diff-cover for the merged branch back above the 90% gate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
romanlutz
added a commit
to romanlutz/PyRIT
that referenced
this pull request
Jun 2, 2026
Brings in 3 new commits from main: - 648faa9 FEAT: Backfill class-level metadata for all remote seed datasets (microsoft#1780) - 092126d MAINT: Migrate AddImage/AddTextImage converter deprecations to print_deprecation_message (microsoft#1875) - 376e000 FEAT: Add TatweelConverter for Arabic kashida insertion (microsoft#1869) Conflict resolution (11 files): took main's version everywhere (`git checkout --theirs`), then re-ran `ruff check --fix` to re-apply the PEP 604 sweep to main's new code (~36 violations auto-fixed). Same hand-fix for the runtime `Optional[dict]` in `pyrit/models/message_piece.py` PlainSerializer `return_type` that ruff can't auto-rewrite. Verification: - ruff check pyrit/ tests/ doc/ - clean - ruff format --check - clean - pytest tests/unit -n 4 - 8977 passed, 5 skipped, 0 failures Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Description
The PyRIT style guide (
.github/instructions/style-guide.instructions.md,Deprecationssection) requires all deprecations to go throughpyrit.common.deprecation.print_deprecation_messageso the message format andDeprecationWarningfiltering stay consistent across the codebase. Three call sites in the prompt-converter package bypassed the helper by emittingFutureWarningdirectly viawarnings.warn. This PR migrates the warning mechanism without resetting the deprecation clock.Sites migrated
pyrit/prompt_converter/add_text_image_converter.py:66-- positionaltext_to_add-> keywordpyrit/prompt_converter/add_image_text_converter.py:86-- positionalimg_to_add-> keywordpyrit/prompt_converter/add_image_text_converter.py:99--x_pos/y_pos->bounding_boxAll three were introduced in #1591 on 2026-04-22, during the
0.14.0.dev0cycle (afterv0.13.0was tagged). They have not shipped in any release yet, so the originally announcedremoved_in="0.15.0"is the next still-pending release and is preserved as-is for all three. The two unusedimport warningsstatements were removed since no otherwarnings.warncalls remain in those files.Audit context (sites intentionally left alone)
pyrit/prompt_target/hugging_face/hugging_face_endpoint_target.py:203andpyrit/prompt_target/hugging_face/hugging_face_chat_target.py:511emit aUserWarningwhen sampling parameters are set withoutdo_sample=True. These are legitimate misconfiguration warnings, not deprecations, so they stay onwarnings.warn.pyrit/auxiliary_attacks/__init__.py:20emits anExperimentalWarningon package import. The module is experimental, not deprecated, so it stays onwarnings.warn.Tests and Documentation
The warning class changes
FutureWarning->DeprecationWarningas a side effect of using the helper, so the three correspondingpytest.warns(...)assertions and onewarnings.simplefilter("error", ...)check intests/unit/prompt_converter/test_add_image_text_converter.pywere updated to match the new class and the helper-generated message text. No JupyText changes -- the deprecation surface is internal to converter construction and not demonstrated in any notebook.Verified locally:
pytest tests/unit/prompt_converter/test_add_text_image_converter.py tests/unit/prompt_converter/test_add_image_text_converter.py -v-- 37 passedpytest tests/unit/prompt_converter/ tests/unit/common/test_deprecation.py -x --timeout=60-- 981 passed, 37 skipped, 0 failedpre-commit run --files ...-- all hooks pass (ruff format, ruff check, ty)