Repository navigation
FIX preserve subclass type for attack result metadata - #3823
Merged
Roman Lutz (romanlutz) merged 1 commit intoNov 3, 2026
Merged
Roman Lutz (romanlutz) merged 1 commit into
Roman Lutz (romanlutz) merged 1 commit into
Conversation
19 of 25 tasks
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the factory’s subclass-preserving typing update.
No open issues 🎉
What changed in this PR
Improves typing precision for AttackResultMetadata.from_metadata as part of #3166, allowing callers to retain the concrete subclass type without changing runtime behavior.
Changes:
- Changes the factory’s return annotation and docstring to
Self. - Adds runtime and
assert_typechecks for subclass construction. - Leaves metadata validation and serialization unchanged.
| File | Description |
|---|---|
tests/unit/models/test_attack_result_metadata.py |
Adds subclass type and field-value checks. |
pyrit/models/results/attack_result_metadata.py |
Uses Self to describe the factory’s existing subclass-preserving behavior. |
Review effort: Balanced
Roman Lutz (romanlutz)
self-requested a review
November 2, 2026 10:16
Slai.life (huong8373tt-beep)
force-pushed
the
fix/p311-01-attack-result-metadata-self-2
branch
3 times, most recently
from
November 2, 2026 12:36
e698a08 to
03d5ad6
Compare
Signed-off-by: Slai.life <huong8373tt@gmail.com>
Slai.life (huong8373tt-beep)
force-pushed
the
fix/p311-01-attack-result-metadata-self-2
branch
from
November 2, 2026 12:50
03d5ad6 to
dae7838
Compare
Roman Lutz (romanlutz)
approved these changes
Nov 3, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 3, 2026
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
Part of #3166. Update
AttackResultMetadata.from_metadatato returnSelf, matching its existingcls(...)construction and preserving the concrete subclass type for callers. Add focused runtime andassert_typecoverage for subclass construction without changing metadata validation or serialization behavior.Tests and Documentation
python -m py_compile pyrit/models/results/attack_result_metadata.py tests/unit/models/test_attack_result_metadata.pytests/unit/models/test_attack_result_metadata.pySlai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.