Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use regex to match overlay annotations #19871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025
Merged

Conversation

kaspersv
Copy link
Contributor

No description provided.

@kaspersv kaspersv requested a review from ginsbach June 25, 2025 07:25
@kaspersv kaspersv marked this pull request as ready for review June 25, 2025 07:25
@Copilot Copilot AI review requested due to automatic review settings June 25, 2025 07:25
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the detection of overlay[...] annotations by replacing a hard-coded list with a regex-based approach.

  • Import and compile a regex pattern to match any overlay[...] annotation.
  • Update has_overlay_annotations to use the compiled pattern instead of explicit string checks.
Comments suppressed due to low confidence (1)

config/add-overlay-annotations.py:25

  • The new regex logic for matching annotations isn’t covered by existing tests. Add unit tests for cases like overlay[local], overlay[caller?], and lines without annotations to ensure correct behavior.
def has_overlay_annotations(lines):

from difflib import context_diff

OVERLAY_PATTERN = re.compile(r'overlay\[[a-zA-Z0-9?_\\-]+\]')
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The character class includes an escaped backslash (\\) which isn't needed for matching overlay annotations. Consider simplifying to something like r'overlay\[[A-Za-z0-9?-]+\]' to make the intent clearer.

Suggested change
OVERLAY_PATTERN = re.compile(r'overlay\[[a-zA-Z0-9?_\\-]+\]')
OVERLAY_PATTERN = re.compile(r'overlay\[[A-Za-z0-9?-]+\]')

Copilot uses AI. Check for mistakes.

@kaspersv kaspersv merged commit 7186ea5 into main Jun 25, 2025
6 checks passed
@kaspersv kaspersv deleted the kaspersv/overlay-script-re branch June 25, 2025 07:39
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