Repository navigation
MAINT: P311-01 extend typing.Self to SeedDataset and Scorable factories - #3266
Merged
Roman Lutz (romanlutz) merged 2 commits intoOct 17, 2026
Merged
Conversation
Contributor
Author
|
@microsoft-github-policy-service agree |
3 of 25 tasks
Roman Lutz (romanlutz)
approved these changes
Oct 16, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 16, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 16, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 16, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 16, 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 (P311-01: Extend
typing.Selfadoption).This PR completes the remaining cases identified for P311-01, adopting Python 3.11's
typing.Selfreturn type annotation across classmethod factories that construct throughclsbut previously annotated a fixed base-class return type, causing subclass invocations to lose their concrete types.Detailed Changes
pyrit/models/seeds/seed_dataset.py:Selffromtyping.SeedDataset.from_dict(cls, ...) -> Self(constructed viacls.model_validate).from_yaml_fileintentionally left untouched: it delegates to a loader that constructs a fixed base class, per the issue's scoping notes.pyrit/models/score/scorable.py:Selffromtyping.MessageScorable.from_message(cls, ...) -> Self(constructed viacls(...)).ContentScorable.from_message(cls, ...) -> Self(constructed viacls(...)).Tests and Documentation
assert_typeregression tests following the pattern merged in MAINT: P311-01 extend typing.Self adoption across classmethod factories #3194 and MAINT: P311-01 extend typing.Self to Message and AtomicAttackIdentifier factories #3201:test_seed_dataset_from_dict_preserves_subclass_typeintests/unit/models/test_seed_dataset.pytest_message_scorable_from_message_preserves_subclass_typeandtest_content_scorable_from_message_preserves_subclass_typeintests/unit/models/test_scorable.pymodel_validateand Pydantic validators) unchanged; no runtime behavior change.ty check pyrit/models tests/unit/modelsreports zero diagnostics;ruff check/ruff format --checkclean on changed files.