Open fry69 opened 1 week ago
Agree that we should avoid reading .gitignore
from parents directories outside the path where deptry
is invoked. We could disable parents when constructing the directory iterator here.
But testing a bit the changes, this made me realise that we probably don't handle .gitignore
properly today. If we disable reading parents, given the following structure:
.
├── requirements.txt
└── src
└── foo.py
where .gitignore
contains *
.
$ deptry .
[...]
Scanning 0 file...
[...]
$ deptry src
[...]
Scanning 1 file...
[...]
Reading .gitignore
file is relative to the directory passed as a positional argument, which is probably not what we want. Seems to me that reading the file from the location deptry
itself is invoked would make more sense, although we should likely also respect .gitignore
in sub-directories (which is probably something that the library we use does automatically).
Tiny addition: There must be some kind of clever library at work, as even if I move the git ignore patterns from .gitignore
to .git/info/exclude
, they still get found in the git repository up in the parent hierarchy.
My setup may be not exactly standard, but
deptry
is the only tool that has a problem with it:Up in my filesystem hierarchy there lingers a Git repository which ignores everything (
*
) and only a few files/directories are excluded from this catch all ignore. This works 100% fine with VSCode Git, command line Git and every other Git related tool I can think of.Only
deptry
refuses to find any file with this setup, as it somehow climbs up in hierarchy to find my.gitignore
->Is there a way to fix this gracefully?