Skip to content

Conversation

@p1c2u
Copy link
Owner

@p1c2u p1c2u commented Feb 11, 2026

This pull request improves the handling of custom path separators in the BasePath class and ensures that all relevant methods and operations respect the separator specified by the user. It also adds comprehensive tests to verify this behavior.

Enhancements to separator handling in BasePath:

  • Updated with_name to check for the instance's separator instead of a global constant, ensuring correct validation for custom separators.
  • Modified is_relative_to and relative_to to pass the instance's separator to parse_args, guaranteeing correct parsing when custom separators are used. [1] [2]
  • Changed __rtruediv__ to preserve the separator when constructing new paths, so that operations like "a" / BasePath("b.c", separator=".") maintain the correct separator.

Expanded test coverage for custom separators:

  • Added test_preserves_separator to verify that the separator is preserved in division operations.
  • Added test_with_name_respects_separator to ensure that with_name raises an error when the new name contains the custom separator.
  • Added test_relative_to_and_is_relative_to_custom_separator to check that relative path operations work correctly with custom separators.

Copy link
Contributor

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 ensures BasePath operations consistently respect an instance’s custom separator, fixing cases where methods accidentally used the default global separator and adding tests to prevent regressions.

Changes:

  • Update with_name validation to reject names containing self.separator (not the global default).
  • Pass sep=self.separator into parse_args for is_relative_to and relative_to.
  • Preserve separator in __rtruediv__ path construction (e.g., "a" / BasePath(..., separator=".")).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pathable/paths.py Propagates instance separator through name validation, relative path parsing, and reverse-division construction.
tests/unit/test_paths.py Adds targeted tests covering separator preservation and relative/name ops with custom separators.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@p1c2u p1c2u merged commit 505fded into master Feb 11, 2026
16 checks passed
@p1c2u p1c2u deleted the fix/separator-correctness-in-core-path-ops branch February 11, 2026 13:57
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.

1 participant