Skip to content

MAINT: Remove the legacy flag-style pyrit_scan invocations - #4429

Merged
Roman Lutz (romanlutz) merged 5 commits into
microsoft:mainfrom
khushi-git-7:maint/4393-pyrit-scan-legacy
Nov 21, 2026
Merged

Roman Lutz (romanlutz) merged 5 commits into
microsoft:mainfrom
khushi-git-7:maint/4393-pyrit-scan-legacy

Conversation

@khushi-git-7

@khushi-git-7 Khushi (khushi-git-7) commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Removes the legacy flag-style pyrit_scan invocations, due in 1.3.0. Closes #4393.

  • Deletes _LEGACY_COMMAND_FLAGS, _warn_legacy and the three legacy rewrites. What remains of _translate_legacy_argv (moving a verb that follows global options to the front, and leaving --help to argparse) is now _move_verb_to_front, and the parse_args and _build_global_parser docstrings are updated.
  • main(): arguments without a verb are now a usage error (exit 2, "a command is required"). Without this, pyrit_scan --start-server and pyrit_scan --list-scenarios would print the top-level help and exit 0. A bare pyrit_scan still prints the help and exits 0.
  • Tests: the legacy-mapping tests are replaced by a parametrized test showing that every legacy form (--list-*, --add-initializer, --stop-server, an implicit <scenario> run, a standalone --start-server) exits 2 without running a command, plus tests that --server-url X list-scenarios and --start-server list-targets still work.
  • Two docstrings that referred to --list-scenarios now say list-scenarios.
  • Moves the remaining callers to subcommands: the adversarial benchmark pipeline now runs pyrit_scan start-server (with a unit test for that command line), and the doc examples in doc/scanner/garak, doc/scanner/airt and doc/code/scenarios/3_adaptive_scenarios (.py and .ipynb) use pyrit_scan run ....

Copilot AI balanced review requested due to automatic review settings November 19, 2026 15:29

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.

🟡 Changes recommended

The benchmark pipeline still uses the removed --start-server invocation, causing the job to exit before benchmarks run; it must be migrated to the start-server subcommand.

1 open issue
What changed in this PR

Removes deprecated flag-style pyrit_scan invocations for the 1.3.0 release, completing the CLI’s transition to explicit subcommands.

Changes:

  • Removes legacy argument rewrites while preserving global-option placement and help behavior.
  • Returns usage errors for commandless arguments and adds regression tests for removed forms.
  • Updates two docstring references to use list-scenarios.
File Description
tests/​unit/​cli/​test_pyrit_scan.py Replaces legacy-mapping tests with rejection, verb-placement, and bare-invocation help tests.
pyrit/​setup/​initializers/​preload_scenario_metadata.py Updates a docstring to name the current subcommand.
pyrit/​scenario/​core/​scenario.py Updates a docstring to name the current subcommand.
pyrit/​cli/​pyrit_scan.py Removes legacy translation and rejects arguments without a command.

Review effort: Balanced

Comment thread pyrit/cli/pyrit_scan.py Resolved
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@romanlutz Roman Lutz (romanlutz) 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.

Reviewed: deprecation window honored (warned since v1.1.0, due in 1.3.0), repo-wide sweep clean, every removed form now exits 2 with a clear usage error, and the benchmark pipeline migration is covered by a unit test. 174 CLI tests pass on the updated branch.

@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 21, 2026
Merged via the queue into microsoft:main with commit dc898c6 Nov 21, 2026
65 checks passed
@khushi-git-7

Copy link
Copy Markdown
Contributor Author

Thanks for the review, the clearer usage error and the merge, Roman Lutz (@romanlutz).

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.

MAINT: Remove the legacy flag-style pyrit_scan invocations (due in 1.3.0)

3 participants