Repository navigation
Replace the deprecated pathspec gitwildmatch factory - #47
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #25.
Summary
load_gitignore_patterns()now builds its.gitignorematcher fromGitIgnoreSpecPatterninstead of pathspec's deprecated'gitwildmatch'name.>=0.12.1to>=1.0.0.Why not the obvious fix
The deprecation message says to use
'gitignore', and #25 proposed that swap. It changes which files are scanned:'gitignore'foo/*foo/, includingfoo/bar/baz.txtfoo/bar/baz.txtis scanned/In pathspec 1.x the deprecated class is declared
class GitWildMatchPattern(GitIgnoreSpecPattern)and adds only the warning. The registered'gitignore'name maps toGitIgnoreBasicPattern, a different implementation that pathspec's own docstring says "differs from how Git actually behaves". PassingGitIgnoreSpecPatterndirectly is identical to the old behaviour by construction.The floor change
GitIgnoreSpecPatterndoes not exist in pathspec 0.12.1 (ModuleNotFoundError). A fresh install already resolved to 1.x,requirements.txtpins 1.1.1, and kospex pinspathspec==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.TestLoadGitignorePatternspinfoo/*, the bare/, negation, directory patterns and the four literals panopticas appends. The deprecation test failed before the change. With'gitignore'swapped in temporarily, thefoo/*and bare/tests fail.identify_files()over this repository returns the same 113 files and filetypes before and after.git check-ignore: no root.gitignorepattern 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