-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(python_file_finder): improve ignore handling #908
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #908 +/- ##
=====================================
Coverage 92.6% 92.6%
=====================================
Files 37 37
Lines 1006 1006
Branches 99 99
=====================================
Hits 932 932
Misses 59 59
Partials 15 15 ☔ View full report in Codecov by Sentry. |
509f541
to
d5d737f
Compare
7eb7c5d
to
4361f55
Compare
@@ -61,9 +61,8 @@ fn build_walker( | |||
|
|||
walk_builder | |||
.types(build_types(ignore_notebooks).unwrap()) | |||
.standard_filters(use_git_ignore) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.rs/ignore/0.4.23/ignore/struct.WalkBuilder.html#method.standard_filters
All the options that standard_filters
set are enabled by default anyway, so this does not change the current behaviour when not overriding exclusion list. But when overriding it, this allows disabling everything related to ignore (because there actually is more than .gitignore
at play).
4217bf7
to
17a3031
Compare
17a3031
to
ca9e39b
Compare
Closes #882.
PR Checklist
docs
is updatedDescription of changes
Currently, if a
.gitignore
file is hanging around in a parent directory that is outside a git repository, deptry will read it. Thinking this through, I believe we should simply avoid reading any.gitignore
altogether if not in a git repository, by not disablingrequire_git
. This is in line with what many tools do in the Python ecosystem, one such example being Ruff.The positive side-effect of doing that is that when in a git repository,
ignore
crate will only read parents directories to find gitignore files up to when it finds a.git
directory, fixing the use case reported in the issue. Newly added tests demonstrate that this fixes the issue.