Some imports are wrongly considered as local ones
mkniewallner opened this issue · 0 comments
mkniewallner commented
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
infoo.py
is a local importimport sub_bar
insub_directory/foo.py
is a local importimport bar
insub_directory/foo.py
is NOT a local import
To Reproduce
Steps to reproduce the behavior:
- Create a project with the structure and imports defined above
- Run
deptry . --json-output output.json; cat output.json
- The following output is returned:
{
"obsolete": [],
"missing": [
"bar"
],
"transitive": [],
"misplaced_dev": []
}
Expected behavior
deptry should assume the following:
import bar
infoo.py
is a local importimport sub_bar
insub_directory/foo.py
is NOT a local import (current behaviour is incorrect, assub_bar
module is not in the root directory)import bar
insub_directory/foo.py
is a local import (current behaviour is incorrect, as there is abar
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.