deptry icon indicating copy to clipboard operation
deptry copied to clipboard

Resolve exclude patterns in pyproject.toml relative to project root

Open kolditz-senec opened this issue 7 months ago • 0 comments

Is your feature request related to a problem? Please describe.

Currently, exclude patterns are resolved relative to the directory deptry is running in. If you run deptry from another directory (or provide an absolute path to the current directory) and point it to a pyproject.toml via --config, where the excludes are listed relative to the project root, it fails to resolve the excludes as expected.

This leads to unexpected behavior, where running deptry on the same directory with the same config yields different results depending on the directory you run deptry from and how you specify the path (relative vs. absolute).

Examples:

# Works as expected
deptry .
# Does not exclude tests etc., unless you exclude the full absolute path
deptry `pwd`
deptry --config pyproject.toml `pwd`
deptry --config /another/dir/pyproject.toml /another/dir

Describe the solution you would like

When reading patterns from a pyproject.toml, match exclude patterns relative to the parent directory of the pyproject.toml file.

kolditz-senec avatar Mar 03 '25 07:03 kolditz-senec