Skip to content

typing: preserve SeedIdentifier subclasses - #3999

Merged
Roman Lutz (romanlutz) merged 1 commit into
microsoft:mainfrom
huong8373tt-beep:feat/py311-seed-identifier
Nov 6, 2026
Merged

Roman Lutz (romanlutz) merged 1 commit into
microsoft:mainfrom
huong8373tt-beep:feat/py311-seed-identifier

Conversation

@huong8373tt-beep

@huong8373tt-beep Slai.life (huong8373tt-beep) commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Annotate SeedIdentifier.from_seed with Self.
  • Add base/subclass runtime and assert_type regression coverage.
  • P311-01: SeedIdentifier.from_seed. Relates to Python 3.11 adoption opportunities: claim one improvement at a time #3166; this focused change does not complete the whole tracker.
  • Runtime factory behavior, behavioral parameter projection, hashes, and serialization are unchanged.

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

Tests and Documentation

Reviewer validation at 7fde440058bfa7c6029544b08c4d3e7263b15fdb:

  • uv run --no-sync pytest tests\unit\models\identifiers\test_atomic_attack_identifier.py -q: passed, 49 tests on Python 3.11.15, 3.12.15, and 3.14.4 using separate worktree-local environments.
  • uv run --no-sync ty check --python-version 3.11 pyrit\models\identifiers\seed_identifier.py tests\unit\models\identifiers\test_atomic_attack_identifier.py: passed on Python 3.11.15.
  • uv run --no-sync ty check --python-version 3.12 pyrit\models\identifiers\seed_identifier.py tests\unit\models\identifiers\test_atomic_attack_identifier.py: passed on Python 3.12.15.
  • uv run --no-sync ty check pyrit\models\identifiers\seed_identifier.py tests\unit\models\identifiers\test_atomic_attack_identifier.py: passed on Python 3.14.4.
  • uv run --no-sync ruff check pyrit\models\identifiers\seed_identifier.py tests\unit\models\identifiers\test_atomic_attack_identifier.py: passed.
  • uv run --no-sync ruff format --check pyrit\models\identifiers\seed_identifier.py tests\unit\models\identifiers\test_atomic_attack_identifier.py: passed.
  • git diff --check: passed.

JupyText and documentation builds were not run locally; no documentation examples changed.

Original author-reported commands (results were not stated in the original body):

  • uv run --frozen --extra all --link-mode=copy pytest tests/unit/models/identifiers/test_atomic_attack_identifier.py -q
  • uv run --frozen --extra all --link-mode=copy ruff check pyrit/models/identifiers/seed_identifier.py tests/unit/models/identifiers/test_atomic_attack_identifier.py
  • uv run --frozen --extra all --link-mode=copy ruff format --check pyrit/models/identifiers/seed_identifier.py tests/unit/models/identifiers/test_atomic_attack_identifier.py
  • uv run --frozen --extra all --link-mode=copy -m ty check pyrit tests/unit
  • git diff --check

Signed-off-by: Slai.life <huong8373tt@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 07:22

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 are reported for the subclass-preserving return-type update to SeedIdentifier.from_seed.

No open issues 🎉

What changed in this PR

This PR extends Python 3.11 Self adoption to SeedIdentifier.from_seed, preserving concrete subclass types in static typing without changing runtime behavior.

Changes:

  • Annotates the factory return type with Self.
  • Adds base/subclass regression coverage using assert_type and runtime type assertions.
File Description
tests/​unit/​models/​identifiers/​test_atomic_attack_identifier.py Adds static and runtime checks for base and subclass factory results.
pyrit/​models/​identifiers/​seed_identifier.py Imports Self and updates the factory return annotation.

Review effort: Balanced

@romanlutz
Roman Lutz (romanlutz) merged commit 2dc57cc into microsoft:main Nov 6, 2026
83 of 84 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