Python-* and *-python named packages are not well recognized
Cajuteq opened this issue · 8 comments
Describe the bug
Using some package with python-* or *-python in their names, the packages are considered obsolete and their "import" name is considered missing
To Reproduce
Steps to reproduce the behavior:
- use ffmpeg-python and python-magic in a fastapi project
- make the install with poetry
- run deptry .
Expected behavior
deptry should recognize python-* and *-python with a warning ; the same way it assumes things on dash and underscores
System [please complete the following information]:
- OS: Windows11 WSL2 Debian
- Language Version: Python 3.9
- Poetry version: Poetry 1.2.2
Additional context
Not critical at all, probably a "good first issue" tag
Hi @Cajuteq! Thanks for raising the issue. At first glance, it seems that these packages are missing a top-level module name. However, given the warnings regarding pylint
and pytest
, it seems more likely that the root-cause is that deptry is not run from within the virtual environment. This would probably be solved by running either:
poetry run deptry .
or
poetry shell
deptry .
I tested this solution by adding the dependencies to my project and running deptry
in verbose mode. The results show that the top-level dependencies are indeed present:
The project contains the following dependencies:
[...]
Dependency 'python-magic' with top-levels: {'magic'}.
Dependency 'ffmpeg-python' with top-levels: {'ffmpeg'}.
Please let me now it this resolves the bug for you as well.
Strange. Could you maybe let us know which version of deptry you are using? (deptry --version
).
Also, since I am not able to reproduce the error, would it be possible to share a minimal pyproject.toml
that would give this error?
Example pyproject.toml
:
[tool.poetry]
name = "deptrytest"
version = "0.0.1"
description = "a"
authors = ["Florian Maas <fpgmaas@gmail.com>"]
repository = "https://github.com/fpgmaas/deptry"
documentation = "https://fpgmaas.github.io/deptry/"
readme = "README.md"
[tool.poetry.dependencies]
python = ">=3.8,<4.0"
ffmpeg-python = "^0.2.0"
python-magic = "^0.4.27"
[tool.poetry.group.dev.dependencies]
deptry = "^0.11.0"
and foo.py
:
import ffmpeg
import magic
Steps:
- place
foo.py
andpyproject.toml
in same directory poetry install
poetry run deptry .
Output:
Scanning 1 file...
Success! No dependency issues found.
It was 0.4.7 which was quite old,
I updated to 0.11.0 and got newly formatted but similar errors
It also seems to think the packages are not installed or configured, although poetry run start
works fine.
I created a minimal folder according to your previous message, and I think it is related to either poetry 1.5.0 or python 3.11 (I mean the potentially cursed flavor installed locally)
The error message you have during poetry install
(file could not be opened successfully
) probably means that dependencies did not get installed. What is the output of poetry show
command?
Indeed, poetry show output shows these packages were not installed in poetry, thanks you all