Repository navigation
FIX: extract indented Perl and Raku use statements - #4753
Closed
ikymory いきもり (ikymory) wants to merge 1 commit into
Closed
ikymory いきもり (ikymory) wants to merge 1 commit into
ikymory いきもり (ikymory) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 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
useand Rakuuse,need,import, andrequire. - 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
Roman Lutz (romanlutz)
requested changes
Nov 29, 2026
Roman Lutz (romanlutz)
left a comment
Contributor
There was a problem hiding this comment.
Seems like a duplicate of #4752 ? If so please close
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. |
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.
PackageHallucinationScorerwithecosystem=PERLorRAKUmisses a module when itsuse(or Raku'sneed/import/require) statement is indented, for example inside aBEGIN/sub/ifblock 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.