Skip to content

FIX preserve subclass type for attack result metadata - #3823

Merged
Roman Lutz (romanlutz) merged 1 commit into
microsoft:mainfrom
huong8373tt-beep:fix/p311-01-attack-result-metadata-self-2
Nov 3, 2026
Merged

Roman Lutz (romanlutz) merged 1 commit into
microsoft:mainfrom
huong8373tt-beep:fix/p311-01-attack-result-metadata-self-2

Conversation

@huong8373tt-beep

Copy link
Copy Markdown
Contributor

Description

Part of #3166. Update AttackResultMetadata.from_metadata to return Self, matching its existing cls(...) construction and preserving the concrete subclass type for callers. Add focused runtime and assert_type coverage 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.py
  • Focused unit tests for tests/unit/models/test_attack_result_metadata.py

Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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_type checks 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

@huong8373tt-beep
Slai.life (huong8373tt-beep) force-pushed the fix/p311-01-attack-result-metadata-self-2 branch 3 times, most recently from e698a08 to 03d5ad6 Compare November 2, 2026 12:36
Signed-off-by: Slai.life <huong8373tt@gmail.com>
@huong8373tt-beep
Slai.life (huong8373tt-beep) force-pushed the fix/p311-01-attack-result-metadata-self-2 branch from 03d5ad6 to dae7838 Compare November 2, 2026 12:50
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 3, 2026
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 3, 2026
Merged via the queue into microsoft:main with commit db3a781 Nov 3, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants