Skip to content

Conversation

@OliverDavey
Copy link
Contributor

Fix for issue #526

@sonarqubecloud
Copy link

@fgmacedo fgmacedo requested a review from Copilot June 4, 2025 01:02
Copy link

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 fixes the Windows path sanitization for module regex matching in the doc build process.

  • Escape backslashes in project_root before building the regex
  • Update the regex to use the sanitized path
  • Ensures tests for Windows-style paths operate correctly
Comments suppressed due to low confidence (1)

tests/scrape_images.py:16

  • [nitpick] Add or update tests covering Windows-style paths to ensure the regex correctly handles backslashes in project_root on Windows environments.
sanitized_path = self.project_root.replace("\\", "\\\\")

def __init__(self, project_root):
self.project_root = project_root
self.re_machine_module_name = re.compile(f"{self.project_root}/(.*).py$")
sanitized_path = self.project_root.replace("\\", "\\\\")
Copy link

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

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

Consider using re.escape(self.project_root) to properly escape all regex metacharacters in the project path instead of manually replacing backslashes.

Suggested change
sanitized_path = self.project_root.replace("\\", "\\\\")
sanitized_path = re.escape(self.project_root)

Copilot uses AI. Check for mistakes.
self.project_root = project_root
self.re_machine_module_name = re.compile(f"{self.project_root}/(.*).py$")
sanitized_path = self.project_root.replace("\\", "\\\\")
self.re_machine_module_name = re.compile(f"{sanitized_path}/(.*).py$")
Copy link

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

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

The regex uses .py without escaping the dot, matching any character before 'py'. Escape the dot (e.g., \\.py$) to match the literal file extension.

Suggested change
self.re_machine_module_name = re.compile(f"{sanitized_path}/(.*).py$")
self.re_machine_module_name = re.compile(f"{sanitized_path}/(.*)\\.py$")

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jun 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b0367f0) to head (430a6cb).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop      #527   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        25           
  Lines         1631      1631           
  Branches       257       257           
=========================================
  Hits          1631      1631           
Flag Coverage Δ
unittests 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 1, 2025

@fgmacedo fgmacedo merged commit 9a089ed into fgmacedo:develop Jul 1, 2025
12 checks passed
@fgmacedo
Copy link
Owner

fgmacedo commented Jul 1, 2025

Thanks @OliverDavey !

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