fpgmaas/deptry

Should the CLI arguments be relative to the current working dir or to the [DIRECTORY] argument?

fpgmaas opened this issue · 0 comments

Question

See also; #91

The first argument to deptry is currently the project's root for which to run deptry. Since deptry is installed within the virtual environment, there should almost never be a reason to enter something else than .. The other arguments are all relative to this directory. This can lead to confusion.

Let's assume we have a directory structure:

my-proj/

├─ my_proj/
│  ├─ main.py
├─ tests/
│  ├─ test.py
├─ req/
│  ├─ req-prod.txt

Right now it would be called as:

deptry . --exclude tests --requirements-txt req/req-prod.txt

We have multiple options:

1. Don't change anything

Keep the arguments as is. The argument seems a little bit useless, since the project's virtual environment needs to be active for deptry to scan a project, and thus deptry will almost always be called as deptry . The fact that this argument is there, mgith lead people to incorrectly believe they can also use it as 'code to be scanned' and try to run e.g. deptry src to scan only the code in the src directory, which will fail.

2 . Remove the first argument [DIRECTORY]

a) Remove the argument and always run deptry within the current working directory.

deptry --exclude tests --requirements-txt req/req-prod.txt

b) Alternatively, make it optional.

3. Change the meaning of the first argument [DIRECTORY]

Change the meaning from 'directory to run in' to 'code to be scanned'. This will lead to some CLI options being relative (--exclude, --extend-exclude), and some being absolute (--requirements-txt)

deptry my_proj --requirements-txt req/req-prod.txt

In this case, we don't need to specify the exclude option. However:

  • this becomes a bit complicated if we have multiple directories that we want to scan within my-proj. Also, I think it's better to explicitly exclude than to explicility include, since we are looking for obsolete dependencies.
  • If within my_proj there is a file we want to ignore we would run:
deptry my_proj --requirements-txt req/req-prod.txt --exclude the_file.py

Now one of the arguments is relative, and the other is absolute. This seems quite confusing.