REFACTOR rename SeedDatasetProvider.fetch_dataset to fetch_dataset_async#1735
Merged
romanlutz merged 4 commits intoMay 15, 2026
Merged
Conversation
…sync Per the project style guide, all async methods must end in '_async'. `SeedDatasetProvider.fetch_dataset` (and its 36 subclass overrides) violated this convention. This commit: - Adds new `fetch_dataset_async` on the base class. - Keeps the legacy `fetch_dataset` as a non-abstract concrete shim that emits `DeprecationWarning` and delegates to `fetch_dataset_async`. This preserves backward compatibility for external CALLERS of the public API. - Adds bidirectional dispatch in the base so external IMPLEMENTERS who override only the legacy `fetch_dataset` continue to work, but `__init_subclass__` emits `DeprecationWarning` at class-definition time pointing them to the new name. - Renames `async def fetch_dataset` to `async def fetch_dataset_async` in all 36 internal subclasses (1 local + 35 remote loaders). - Renames `.fetch_dataset(...)` call sites to `.fetch_dataset_async(...)` in all internal callers (tests, end-to-end test, integration smoke test, doc notebook pair). - Adds 5 new unit tests covering the deprecation bridge in both directions. All 655 dataset/setup/executor unit tests pass; ruff lint and format are clean. End-to-end discovery via `SeedDatasetProvider.get_all_providers()` still works. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
hannahwestra25
approved these changes
May 15, 2026
Per @hannahwestra25's review feedback on microsoft#1735, specify the planned removal version in all three DeprecationWarning messages, matching the convention used elsewhere in the codebase (e.g., prompt_target.py, audio_transcript_scorer.py). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-rename' into romanlutz/fetch-dataset-async-rename
eeee2345
added a commit
to eeee2345/PyRIT
that referenced
this pull request
May 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.
What
Renames
SeedDatasetProvider.fetch_dataset(and its 36 subclass overrides) tofetch_dataset_async, with a non-breaking deprecation bridge for both callers and external implementers.Why
The project style guide mandates that all async functions and methods end in
_async.SeedDatasetProvider.fetch_datasetwas a long-standing systemic violation — surfaced during the review of #1715 (review comment).How
pyrit/datasets/seed_datasets/seed_dataset_provider.py):fetch_dataset_asyncis the new primary contract.fetch_datasetis kept as a non-abstract concrete shim that emitsDeprecationWarningand delegates tofetch_dataset_async. Preserves backward compatibility for external callers of the public API.fetch_datasetcontinue to work;__init_subclass__emitsDeprecationWarningat class-definition time pointing them to the new name.NotImplementedErroris raised on call.async def fetch_dataset→async def fetch_dataset_async.tests/unit/datasets/,tests/integration/datasets/,tests/end_to_end/,tests/unit/executor/attack/single_turn/test_many_shot_jailbreak.py,doc/code/datasets/4_dataset_coding.{py,ipynb}): renamed.fetch_dataset(...)→.fetch_dataset_async(...).TestFetchDatasetDeprecationcover both directions of the deprecation bridge plus the no-overrideNotImplementedErrorpath.Out of scope
fetch_dataseton_AgentThreatRulesDataset. After this lands, that PR will need a small follow-up rename (one line). I'll leave a note on [DRAFT] FEAT add Agent Threat Rules (ATR) adversarial payload dataset loader #1715.fetch_datasets_async(plural batch loader) was already correctly named._fetch_from_url,_fetch_from_public_url, etc.) — separate concern.Verification
uv run pytest tests/unit/datasets tests/unit/setup tests/unit/executor/attack/single_turn/test_many_shot_jailbreak.py -n 4— 655 passeduv run pytest tests/end_to_end/test_all_datasets.py -k "XSTest or SimpleSafety"— 2 passed (e2e discovery still works)uv run ruff checkanduv run ruff format --check— cleanuv run pre-commit run --all-files— all hooks pass