Skip to content

Replace the deprecated pathspec gitwildmatch factory - #47

Merged
sabbaticas merged 1 commit into
mainfrom
fix/pathspec-gitwildmatch-deprecation
Oct 11, 2026
Merged

sabbaticas merged 1 commit into
mainfrom
fix/pathspec-gitwildmatch-deprecation

Conversation

@sabbaticas

Copy link
Copy Markdown
Contributor

Closes #25.

Summary

  • load_gitignore_patterns() now builds its .gitignore matcher from GitIgnoreSpecPattern instead of pathspec's deprecated 'gitwildmatch' name.
  • Which files are ignored is unchanged.
  • The pathspec floor moves from >=0.12.1 to >=1.0.0.
  • The test suite's 168 deprecation warnings are gone.

Why not the obvious fix

The deprecation message says to use 'gitignore', and #25 proposed that swap. It changes which files are scanned:

Pattern Before, and Git With 'gitignore'
foo/* Ignores everything under foo/, including foo/bar/baz.txt Ignores only direct children; foo/bar/baz.txt is scanned
a bare / Ignores nothing Ignores every file

In pathspec 1.x the deprecated class is declared class GitWildMatchPattern(GitIgnoreSpecPattern) and adds only the warning. The registered 'gitignore' name maps to GitIgnoreBasicPattern, a different implementation that pathspec's own docstring says "differs from how Git actually behaves". Passing GitIgnoreSpecPattern directly is identical to the old behaviour by construction.

The floor change

GitIgnoreSpecPattern does not exist in pathspec 0.12.1 (ModuleNotFoundError). A fresh install already resolved to 1.x, requirements.txt pins 1.1.1, and kospex pins pathspec==1.1.1, so only an environment pinning pathspec below 1.0 is affected.

Testing

  • pytest -W error::DeprecationWarning: 768 passed, on pathspec 1.1.1 and on 1.0.0, the new floor.
  • Eleven new tests in TestLoadGitignorePatterns pin foo/*, the bare /, negation, directory patterns and the four literals panopticas appends. The deprecation test failed before the change. With 'gitignore' swapped in temporarily, the foo/* and bare / tests fail.
  • identify_files() over this repository returns the same 113 files and filetypes before and after.
  • Across 167 cloned repositories (237,318 files) the matcher was compared with git check-ignore: no root .gitignore pattern was interpreted differently. The structural differences that comparison found are unrelated to this change and are recorded in File selection differs from Git: tracked-but-ignored files, nested .gitignore, no .gitignore #46.

Not covered

Two malformed patterns (an invalid range such as a[b-a]c, and a lone backslash) make pathspec raise with every matcher, old and new. Existing behaviour, unchanged here.

🤖 Generated with Claude Code

load_gitignore_patterns() built its matcher with a factory pathspec
deprecated in 1.0.0, raising a DeprecationWarning on every call and set
to break when the name is removed. It now passes GitIgnoreSpecPattern
directly. The deprecated class was a thin subclass of it, so which files
are ignored is unchanged.

The registered 'gitignore' name, which the deprecation message suggests,
is deliberately not used. It is GitIgnoreBasicPattern, a different
implementation: "foo/*" stops ignoring foo/bar/baz.txt and a bare "/"
ignores every file. New tests pin both.

GitIgnoreSpecPattern does not exist before pathspec 1.0.0, so the floor
moves from >=0.12.1 to >=1.0.0.

Closes #25

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sabbaticas
sabbaticas merged commit 1e08e30 into main Oct 11, 2026
5 checks passed
@sabbaticas
sabbaticas deleted the fix/pathspec-gitwildmatch-deprecation branch October 11, 2026 01:07
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.

Replace deprecated 'gitwildmatch' pathspec factory with 'gitignore'

1 participant