Skip to content

MAINT: Make HackAPromptTarget._decode_part keyword-only - #4854

Open
Aditya Malkar (adimalkar) wants to merge 2 commits into
microsoft:mainfrom
adimalkar:maint/4216-hackaprompt-kwonly
Open

Aditya Malkar (adimalkar) wants to merge 2 commits into
microsoft:mainfrom
adimalkar:maint/4216-hackaprompt-kwonly

Conversation

@adimalkar

Copy link
Copy Markdown
Contributor

Description

Make HackAPromptTarget._decode_part keyword-only, and clear it from the keyword-only baseline.

  • _decode_part takes line and prefix after *, and its two callers in _parse_stream (the finish part and the text part) pass them by name.
  • Remove its entry from build_scripts/keyword_only_baseline.txt.
  • No behavior change. It is a private classmethod, nothing overrides it, and nothing outside the class calls it.
  • HackAPromptChallenge.__init__ and __new__ stay in the baseline: they are in the public bucket and out of scope for this PR.
  • New tests call it by keyword for a text part and a finish part, check that a part that does not parse names its prefix in the error, and check that a positional call raises TypeError.

python -m build_scripts.check_keyword_only_params passes, the target's 57 unit tests pass, and ruff and ty are clean on both files.

Relates to #4216

This change was developed with AI assistance (Claude Code).

Copilot AI balanced review requested due to automatic review settings December 5, 2026 00:55

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.

🟢 Approval recommended

No active review issues block the keyword-only helper migration.

No open issues 🎉

What changed in this PR

Advances #4216’s private-helper cleanup by making HackAPromptTarget._decode_part keyword-only while preserving parsing behavior.

Changes:

  • Updates the helper signature and both internal callers.
  • Removes its keyword-only baseline entry.
  • Adds tests for decoding, parse errors, and positional-argument rejection.
File Description
tests/​unit/​prompt_target/​target/​test_hack_a_prompt_target.py Tests decoding behavior and keyword-only enforcement.
pyrit/​prompt_target/​hack_a_prompt_target.py Makes _decode_part keyword-only and updates callers.
build_scripts/​keyword_only_baseline.txt Removes the migrated helper’s baseline entry.

Review effort: Balanced

This branch has not been deployed

No deployments
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