Repository navigation
typing: preserve SeedIdentifier subclasses - #3999
Merged
Roman Lutz (romanlutz) merged 1 commit intoNov 6, 2026
Merged
Roman Lutz (romanlutz) merged 1 commit into
Roman Lutz (romanlutz) merged 1 commit into
Conversation
Signed-off-by: Slai.life <huong8373tt@gmail.com>
Contributor
There was a problem hiding this comment.
🟢 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_typeand 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
Roman Lutz (romanlutz)
self-requested a review
November 6, 2026 09:41
10 of 25 tasks
Roman Lutz (romanlutz)
approved these changes
Nov 6, 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
SeedIdentifier.from_seedwithSelf.assert_typeregression coverage.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.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 -quv run --frozen --extra all --link-mode=copy ruff check pyrit/models/identifiers/seed_identifier.py tests/unit/models/identifiers/test_atomic_attack_identifier.pyuv run --frozen --extra all --link-mode=copy ruff format --check pyrit/models/identifiers/seed_identifier.py tests/unit/models/identifiers/test_atomic_attack_identifier.pyuv run --frozen --extra all --link-mode=copy -m ty check pyrit tests/unitgit diff --check