Skip to content

Resolve exclude patterns in pyproject.toml relative to project root #1079

@kolditz-senec

Description

@kolditz-senec

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions