Enhance path type detection for posix and windows paths in fieldtypes#200
Enhance path type detection for posix and windows paths in fieldtypes#200
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #200 +/- ##
==========================================
- Coverage 83.27% 83.26% -0.02%
==========================================
Files 35 35
Lines 3696 3705 +9
==========================================
+ Hits 3078 3085 +7
- Misses 618 620 +2
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:
|
There was a problem hiding this comment.
Pull request overview
This PR enhances path type detection in the fieldtypes module by adding string path support to the _is_posixlike_path() and _is_windowslike_path() helper functions. Previously, these functions only handled pathlib.PurePath objects; now they can also detect path types from raw string paths, enabling the path class to correctly determine whether a string argument represents a POSIX or Windows path.
- Added string detection logic to
_is_posixlike_path()(checks for "/" without "\") - Added string detection logic to
_is_windowslike_path()(checks for Windows drive pattern or "\") - Updated tests to reflect new behavior where strings are now properly type-detected
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| flow/record/fieldtypes/init.py | Added string path type detection to _is_posixlike_path() and _is_windowslike_path() helper functions |
| tests/fieldtypes/test_fieldtypes.py | Updated test expectations to reflect that string "/foo/bar" is now correctly detected as POSIX-like, and adjusted test_path_multiple_parts to expect posix_path when the first argument is a POSIX-like string |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Erik Schamper <1254028+Schamper@users.noreply.github.com>
fixes #199