Skip to content

Preserve custom patterns during automatic backend selection - #162

Merged
cpburnz merged 1 commit into
cpburnz:masterfrom
harbinresearcher:codex/preserve-custom-patterns
Oct 16, 2026
Merged

cpburnz merged 1 commit into
cpburnz:masterfrom
harbinresearcher:codex/preserve-custom-patterns

Conversation

@harbinresearcher

@harbinresearcher harbinresearcher commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #161.

PathSpec accepts custom Pattern implementations, but installing RE2 or Hyperscan causes the default backend to reject them. Select the existing simple backend when automatic selection encounters a non-RegexPattern. Explicit native selection, GitIgnoreSpec, and ordinary regex patterns retain their existing behavior.

Four regression methods exercise custom construction, callable factories, mixed include/exclude patterns and indices, negation, and + / +=. Constructor documentation describes the fallback.

Validation

  • Pristine RED: four methods produced 11 subtest errors. Patched regressions pass.
  • Linux CPython 3.12.15 with both native engines installed: baseline 266 tests OK, patched 270 tests OK, both with 1 skip.
  • Windows CPython 3.12.14 with both native engines installed: baseline 266 tests OK, patched 270 tests OK, both with 16 skips. Windows 3.9 also reports 270 tests OK, with 645 skipped native/symlink subtests because optional engines were not installed there.
  • Strict Sphinx HTML build, source distribution and wheel-from-sdist build passed. Installing that wheel and using custom patterns under all three backend preferences returns the expected matches.
  • git diff --check passed. Mypy and Pyright retain exactly the same diagnostics as pristine master: 2 and 6 errors respectively. Type checking is not claimed as passing.

AI-assisted investigation, implementation, tests and read-only review with OpenAI Codex (GPT-6). No human maintainer review is claimed.

Remote CI: Test Cross run 38234033566 requires maintainer approval (action_required). No remote test pass is claimed.

Select the simple PathSpec backend for non-RegexPattern inputs so optional native engines do not break the public Pattern interface. Cover construction, factories, mixed matching and addition. Fixes cpburnz#161.
@cpburnz

cpburnz commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Thanks for finding and fixing this.

@cpburnz
cpburnz merged commit c86245d into cpburnz:master Oct 16, 2026
6 of 7 checks passed
cpburnz added a commit that referenced this pull request Oct 16, 2026
cpburnz added a commit that referenced this pull request Oct 16, 2026
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.

Default backend rejects custom Pattern implementations when native engines are installed

2 participants