REFACTOR: Promote scorer-initializer module constants to ClassVar (21 items) - #1974
Merged
romanlutz merged 1 commit intoJun 10, 2026
Merged
Conversation
Move 21 module-level UPPER_CASE string constants from pyrit/setup/initializers/components/scorers.py onto ScorerInitializer as ClassVar, matching the pattern from microsoft#1964 and microsoft#1965 and the PyRIT style guide rule that class-only constants live on their class. No value changes. No behaviour changes. Verified: ruff / ty / pytest tests/unit/setup/. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rlundeen2
approved these changes
Jun 9, 2026
This was referenced Jun 9, 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
Promote 21 module-level
UPPER_CASEstring constants inpyrit/setup/initializers/components/scorers.pyonto theScorerInitializerclass asClassVar[str](and_PREFERRED_BESTasClassVar[dict[str, tuple[str, str]]]). Each constant is used only byScorerInitializer, so colocating it with the class better matches thePyRIT style guide.
This is the largest single-file diff in the constants-audit cleanup
plan and follows the same pattern as #1964 (backend / registry / setup)
and #1965 (prompt_converter).
Constants promoted (21)
MAIN_SCORER_TARGET,FALLBACK_SCORER_TARGETMAIN,FALLBACKREFUSAL_GPT4O_OBJECTIVE_STRICT,REFUSAL_GPT4O_OBJECTIVE_LENIENT,REFUSAL_GPT4O_NO_OBJECTIVE_STRICT,REFUSAL_GPT4O_NO_OBJECTIVE_LENIENT,REFUSAL_GPT5_1,REFUSAL_GPT4O_UNSAFEINVERTED_REFUSALACS_THRESHOLD_01,ACS_THRESHOLD_07,ACS_WITH_REFUSALSCALE_AND_REFUSALACS_HATE,ACS_SELF_HARM,ACS_SEXUAL,ACS_VIOLENCETASK_ACHIEVED_GPT4O_TEMP9_PREFERRED_BESTConstants kept at module level
GPT4O_TARGET,GPT4O_TEMP0_TARGET,GPT4O_TEMP9_TARGET,GPT4O_UNSAFE_TARGET,GPT4O_UNSAFE_TEMP0_TARGET,GPT4O_UNSAFE_TEMP9_TARGET,GPT5_4_TARGET,GPT5_1_TARGET—imported by name from
tests/unit/setup/test_scorer_initializer.py, so promoting themwould be a breaking change.
REFUSAL_GPT5_4,ACS_THRESHOLD_05,SCALE_GPT4O_TEMP9_THRESHOLD_09,TASK_ACHIEVED_REFINED_GPT4O_TEMP9— referenced byScorerInitializer._PREFERRED_BESTand out of scope for this PR.No back-compat re-exports needed
None of the 21 promoted constants are imported by name from any other
module under
pyrit/,tests/, ordoc/(verified with grep). Alltest references use string literals, not symbol imports.
No value changes. No behaviour changes.
Verified
uv run --link-mode=copy ruff check pyrit/setup/initializers/components/scorers.pyuv run --link-mode=copy ty check pyrit/setup/initializers/components/scorers.pyuv run --link-mode=copy pytest tests/unit/setup/ -x --no-header -q→ 274 passed