fpgmaas/deptry

[Feature Request] `--config` relative to `root`

Opened this issue ยท 1 comments

Congratulations on the project! ๐Ÿ˜„

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

Right now the --config option is not relative to the root argument. That can cause some troubles if a person is executing the command from a different directory than the root.

If I want to execute deptry in a folder below my current folder, I'd need to run deptry path/to/folder --config path/to/folder/pyproject.toml, otherwise the command would look for pyproject.toml in my current directory.

This approach works, but is not very ergonometric to repeat the whole path twice, and besides that, if I want to read a bunch of paths from a file and execute on those paths, I'd need to cat list_of_paths.txt | xargs deptry --config {some bash magic} which is a bit painful.

Describe the solution you would like

--config path be relative to root

What you suggest is similar to the behaviour deptry used to have before https://github.com/fpgmaas/deptry/releases/tag/0.7.0 got released. In the past, we did not have any way to pass --config, meaning that the CLI always assumed that pyproject.toml was in the directory passed as an argument.

I get how convenient this would be in some situations if the CLI would consider pyproject.toml based on the directory passed as an argument, but I believe that some users might think otherwise, and would expect the option to be relative to the location where the CLI is run. I think this is also more in line with what most other code quality tools do in the Python ecosystem.

As an alternative, maybe we should consider looking for multiple pyproject.toml instead? For instance in your example, running deptry path/to/folder (without passing --config) would search for a pyproject.toml automatically in path/to/folder, and if not found could fallback to a pyproject.toml in the location where the CLI is run from. This might create some complexity though, as one could have a pyproject.toml in the directory, but without anything related to deptry configuration, which could be located in the directory deptry is run from. I think we could take example from what Ruff does though, e.g. also checking if a configuration for deptry exists in pyproject.toml to consider it.