fpgmaas/deptry

Some imports are wrongly considered as local ones

mkniewallner opened this issue · 0 comments

Describe the bug

Given the following project structure:

sub_directory
  foo.py
  sub_bar.py
foo.py
bar.py

deptry will assume the following:

  • import bar in foo.py is a local import
  • import sub_bar in sub_directory/foo.py is a local import
  • import bar in sub_directory/foo.py is NOT a local import

To Reproduce

Steps to reproduce the behavior:

  1. Create a project with the structure and imports defined above
  2. Run deptry . --json-output output.json; cat output.json
  3. The following output is returned:
{
    "obsolete": [],
    "missing": [
        "bar"
    ],
    "transitive": [],
    "misplaced_dev": []
}

Expected behavior

deptry should assume the following:

  • import bar in foo.py is a local import
  • import sub_bar in sub_directory/foo.py is NOT a local import (current behaviour is incorrect, as sub_bar module is not in the root directory)
  • import bar in sub_directory/foo.py is a local import (current behaviour is incorrect, as there is a bar module in the root directory)

With the same setup as above, when running deptry . --json-output output.json; cat output.json, the following should be returned:

{
    "obsolete": [],
    "missing": [
        "sub_bar"
    ],
    "transitive": [],
    "misplaced_dev": []
}

System:

  • OS: Arch Linux
  • Language Version: Python 3.10
  • Poetry version: Poetry 1.2.2

Additional context

Instead of using the current directory here, deptry should use the root directory from which it is run.