Skip to content

MAINT: Bring GCG under Ruff and ty checks#2218

Open
romanlutz wants to merge 2 commits into
microsoft:mainfrom
romanlutz:romanlutz-gcg-tooling-cleanup
Open

MAINT: Bring GCG under Ruff and ty checks#2218
romanlutz wants to merge 2 commits into
microsoft:mainfrom
romanlutz:romanlutz-gcg-tooling-cleanup

Conversation

@romanlutz

Copy link
Copy Markdown
Contributor

Description

GCG was excluded from repository-wide Ruff and ty enforcement, allowing its implementation to drift from current project standards. This change removes those exclusions and makes the GCG prompt generator pass the same formatting, linting, and type-checking gates as the rest of pyrit/.

The cleanup adds precise typing and documentation, replaces suppressed findings with explicit validation, and preserves the legacy LengthPreservingFilter(filter=...) keyword while introducing the clearer enabled name. It also fixes the non-verbose optimization loop so it iterates prompt indices consistently with the verbose path and adds fail-fast checks for invalid worker and gradient states.

The local ty hook now installs the all extra so optional GCG dependencies such as torch are available during checking.

Tests and Documentation

  • uv run --no-sync pre-commit run check-yaml --files .pre-commit-config.yaml
  • uv run --no-sync pre-commit run ruff-format --all-files
  • uv run --no-sync pre-commit run ruff-check --all-files
  • uv run --no-sync pre-commit run ty-check --all-files
  • uv run --no-sync pytest -q tests\unit\executor\promptgen\gcg (172 passed)

Updated GCG API and implementation docstrings as required by the newly enabled Ruff rules. JupyText was not run because no notebook or documentation sample changed.

Copilot AI added 2 commits July 16, 2026 11:00
Bring the GCG prompt generator under the repository Ruff and ty checks, clean up the implementation to satisfy those checks, and preserve compatibility for the candidate filter API.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e5f725f4-b97c-4fb9-b49c-a1db82f68399
Exercise the validation, logging, worker startup, annealing, and extension error paths added by the GCG tooling cleanup.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e5f725f4-b97c-4fb9-b49c-a1db82f68399
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