Skip to content

FIX: extract indented Perl and Raku use statements - #4753

Closed
ikymory いきもり (ikymory) wants to merge 1 commit into
microsoft:mainfrom
ikymory:fix-indented-perl-raku-use
Closed

ikymory いきもり (ikymory) wants to merge 1 commit into
microsoft:mainfrom
ikymory:fix-indented-perl-raku-use

Conversation

@ikymory

Copy link
Copy Markdown

PackageHallucinationScorer with ecosystem=PERL or RAKU misses a module when its use (or Raku's need/import/require) statement is indented, for example inside a BEGIN/sub/if block or inside a code block nested in a list.

Both patterns anchor with (?:{3}|^), so the keyword must be the first character of the line. The Python and Ruby patterns already allow leading whitespace (^[ \t]*import, ^[ \t]*require`); Perl and Raku were left behind.

This changes the anchor to (?:{3}|^[ \t]*)for both ecosystems. Added a parametrized regression test covering space/tab indentation and all four Raku keywords. Verified the updated patterns extractFake::Modulefrom every case with a standalone regex check; the full pytest suite could not run here becauseaiosqlite` is not installed.

Copilot AI balanced review requested due to automatic review settings November 29, 2026 13:12

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 were identified for the change supporting indented Perl and Raku module statements.

No open issues 🎉

What changed in this PR

Fixes PackageHallucinationScorer extraction of indented Perl and Raku module statements, including statements inside nested code blocks.

Changes:

  • Allows leading spaces and tabs before Perl use and Raku use, need, import, and require.
  • Adds six parameterized regression cases covering indentation and supported Raku keywords.
File Description
tests/​unit/​score/​test_package_hallucination_scorer.py Adds regression cases for indented module statements.
pyrit/​score/​true_false/​regex/​package_hallucination_scorer.py Updates Perl and Raku regex anchors to accept leading spaces and tabs.

Review effort: Balanced

@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.

Seems like a duplicate of #4752 ? If so please close

@romanlutz

Copy link
Copy Markdown
Contributor

Closing as a duplicate of #4752, as noted in my review: it makes the same change for #4751 and was opened first, by the reporter. Thanks for the contribution regardless.

To avoid duplicated effort, please check for an existing issue and PR, and claim an issue by comment before starting work, so maintainers can coordinate.

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.

3 participants