-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deptry should never mark the project as transitive dependency #295
Comments
Hi, thanks for the detailed report and reproduction repository, appreciate it. To determine if a module is local or not, Lines 117 to 123 in 41685dc
In your reproduction repository, running $ pdm run deptry src
Scanning 2 files...
Success! No dependency issues found. I do believe that the behaviour might feel a bit weird though, as there would be situations where we want to only check a specific directory while keeping the same "root" directory for Having the ability to explicitly set the source paths as highlighted in #177 would probably solve that. |
Hi, thanks for the reply! Indeed, I ran I have not experimented with pre-commit enough, but if I run
I guess that makes sense. I feel that we might still default to Available to help if needed! |
@baggiponte thanks for raising the issue and the example repository.
The reason the error is raised when you run
This would be a good idea, however, we are currently trying to move away from expecting directories to have an
This might be a nice addition, however there are also plenty of cases where this does not hold; See for example I think in your example repository (and any other repositories with the |
Oh, and maybe to clarify; the reason it is marked as a transitive dependency is as follows: A transitive dependency is identified by (1) a package being available in the local environment, (2) said package being imported in the code and (3) there is an import from this package in the source code of your repository but (4) the package is not listed as a dependency. This for example flags the use of In this case, since PDM installs the package locally in the environment in editable mode, (1), (2), (3) and (4) are all true. So it is (incorrectly) flagged as a transitive dependency. |
Shouldn't condition 4 above be "the package is not listed as a dependency and is also not the package being examined"? It is never correct to list a package as a dependency of itself, but it is fine to import things from the package elsewhere in the package. In my case I am running |
I have a similar issue. When I run deptry in a uv project. It always lists the project itself as a transitive dependency. Even when I run it with uv run. Is this desired? I'm pretty new to this stuff, so I can't really tell. |
Is your feature request related to a problem? Please describe.
When running
deptry
on my source code, I always get the module itself marked as a transitive dependency.For a minimal, reproducible example, see this repo. Here is a summary.
My code resides in
src/deptry_test
. The folder structure is this:In
mod.py
I define a random variable containing gibberish. This var is imported in the__init__.py
.When I run
pdm run deptry src .
, I get an error message becausedeptry_test
is a transitive dependency (see log).Detailed Log
As a side note, IIUC this should not even be marked as transitive dependency, am I right?
Describe the solution you would like
deptry
should automatically add asknown-first-party
the package/project itself usingpyproject.toml
'sproject.name
key.Of course, would love to work on a PR for this if you feel this should be addressed!
The text was updated successfully, but these errors were encountered: