Repository navigation
MAINT: Fix ty unsound-assignment findings in executor, scenario, converter and prompt_normalizer (UA-2) - #4544
Merged
Roman Lutz (romanlutz) merged 2 commits intoNov 21, 2026
Conversation
…erter and prompt_normalizer (UA-2)
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
One or more reviewer sessions failed, leaving the review evidence incomplete.
No open issues 🎉
What changed in this PR
Advances the staged rollout in #4402 by resolving seven ty unsound-assignment findings across PyRIT’s executor, scenario, converter, and prompt-normalizer components.
Changes:
- Adds targeted casts and preserves callable parameter and return types through the JSON retry decorator.
- Validates TAP tree metadata and attack converter configurations, with regression tests for malformed values.
- Removes the seven resolved files from the temporary type-checking override.
| File | Description |
|---|---|
tests/unit/scenario/core/test_attack_technique_factory.py |
Tests rejection of malformed converter configurations during compatibility checks. |
tests/unit/scenario/core/test_attack_technique_factory_converter_composition.py |
Covers absent configurations and malformed values with or without extra converters. |
tests/unit/executor/attack/multi_turn/test_tree_of_attacks.py |
Tests empty and rooted trees, plus invalid metadata rejection. |
pyrit/scenario/scenarios/foundry/assert_policy.py |
Casts the resolved system-prompt parameter to its declared type. |
pyrit/scenario/core/attack_technique_factory.py |
Validates converter configurations before compatibility checks and composition. |
pyrit/prompt_normalizer/prompt_normalizer.py |
Casts batch results to the callback’s known message-list type. |
pyrit/prompt_normalizer/json_retry.py |
Returns the now-typed retry result directly. |
pyrit/executor/attack/single_turn/many_shot_jailbreak.py |
Casts the bundled dataset to its expected structure. |
pyrit/executor/attack/multi_turn/tree_of_attacks.py |
Requires stored visualizations to be a Tree or None. |
pyrit/exceptions/exception_classes.py |
Preserves callable types through pyrit_json_retry. |
pyrit/converter/decomposition_converter.py |
Casts capture-free tokenizer results to list[str]. |
pyproject.toml |
Enables unsound-assignment checking for the seven resolved files. |
Review effort: Balanced
Roman Lutz (romanlutz)
approved these changes
Nov 21, 2026
Roman Lutz (romanlutz)
enabled auto-merge
November 21, 2026 18:55
Roman Lutz (romanlutz)
added a commit
to romanlutz/PyRIT
that referenced
this pull request
Nov 22, 2026
Resolve the pyproject.toml conflict with microsoft#4544 (UA-2): both changes remove their own files from the temporary unsound-assignment override, so the merged list drops the UA-2 and the GCG entries. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.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.
UA-2 from #4402: the rest of
pyrit/executor, pluspyrit/scenario,pyrit/converterandpyrit/prompt_normalizer.Description
Resolve the seven UA-2
unsound-assignmentfindings and remove their files from the temporary ty override. #4402list[str]. The tokenizer pattern has no capture groups.TreeorNone.list[dict[str, str]].list[Message]. The supplied callback returns aMessage.create()andcan_append_request_converter(). Creation can select an override and append converters. Compatibility inspects the baked request chain.str | None. Parameter resolution supplies that type.I chose the local batch cast to keep the change within UA-2. A generic batch helper would also require edits in the target and scorer packages. I used a cast for the bundled dataset because the tracked file supplies the expected shape. The alternative is to validate the schema each time the file loads.
None of the findings represented a runtime bug in normal use with the expected types. The two validation changes make malformed values raise
TypeError.test_tap_attack_result_tree_visualization_rejects_invalid_metadatachecks rejection of0and"invalid".test_tap_attack_result_tree_visualization_getter_returns_valuechecks that the getter returns the sameTreeobject, with and without a root. The factory tests aretest_baked_value_that_is_not_a_converter_config_raisesandtest_can_append_request_converter_rejects_baked_value_that_is_not_a_converter_config.Public Python API output
Checks
make ty(ty overpyritandtests/unit): all checks passed.scenario,executor,converter,prompt_normalizer,prompt_target,scoreandexceptions: all passed.