Skip to content

MAINT: P311-01 extend typing.Self to SeedDataset and Scorable factories - #3266

Merged
Roman Lutz (romanlutz) merged 2 commits into
microsoft:mainfrom
vito233:p311-01-self-factories
Oct 17, 2026
Merged

Roman Lutz (romanlutz) merged 2 commits into
microsoft:mainfrom
vito233:p311-01-self-factories

Conversation

@vito233

Copy link
Copy Markdown
Contributor

Description

Part of #3166 (P311-01: Extend typing.Self adoption).

This PR completes the remaining cases identified for P311-01, adopting Python 3.11's typing.Self return type annotation across classmethod factories that construct through cls but previously annotated a fixed base-class return type, causing subclass invocations to lose their concrete types.

Detailed Changes

  • pyrit/models/seeds/seed_dataset.py:
    • Imported Self from typing.
    • Updated SeedDataset.from_dict(cls, ...) -> Self (constructed via cls.model_validate).
    • from_yaml_file intentionally left untouched: it delegates to a loader that constructs a fixed base class, per the issue's scoping notes.
  • pyrit/models/score/scorable.py:
    • Imported Self from typing.
    • Updated MessageScorable.from_message(cls, ...) -> Self (constructed via cls(...)).
    • Updated ContentScorable.from_message(cls, ...) -> Self (constructed via cls(...)).

Tests and Documentation

@vito233

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2026
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2026
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2026
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2026
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 17, 2026
Merged via the queue into microsoft:main with commit 5c1b506 Oct 17, 2026
98 of 99 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.

2 participants