-
-
Notifications
You must be signed in to change notification settings - Fork 101
Fix: Sanitise project path on windows for doc build #527
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
Fix: Sanitise project path on windows for doc build #527
Conversation
|
There was a problem hiding this 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_rootbefore 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_rooton Windows environments.
sanitized_path = self.project_root.replace("\\", "\\\\")
tests/scrape_images.py
Outdated
| 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("\\", "\\\\") |
Copilot
AI
Jun 4, 2025
There was a problem hiding this comment.
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.
| sanitized_path = self.project_root.replace("\\", "\\\\") | |
| sanitized_path = re.escape(self.project_root) |
tests/scrape_images.py
Outdated
| 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$") |
Copilot
AI
Jun 4, 2025
There was a problem hiding this comment.
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.
| self.re_machine_module_name = re.compile(f"{sanitized_path}/(.*).py$") | |
| self.re_machine_module_name = re.compile(f"{sanitized_path}/(.*)\\.py$") |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
Thanks @OliverDavey ! |



Fix for issue #526