Skip to content
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

Support multiple source roots #622

Open
JettJones opened this issue Mar 18, 2024 · 1 comment
Open

Support multiple source roots #622

JettJones opened this issue Mar 18, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@JettJones
Copy link

Is your feature request related to a problem? Please describe.
I'm trying to run deptry on a project/monorepo setup with https://www.pantsbuild.org/

This leads to some broken expectations

  • no pyproject.toml exists. Pants.toml defines our build.
  • internal projects use root_patterns for relative imports

So I can run deptry, and point to a shared requirements.txt file, but without defining import paths, I'll end up with hundreds of errors like:

`DEP001 'internal_library' imported but missing from the dependency definitions

Describe the solution you would like
I'd like to be able to use deptry scanning directly with pants.toml defined requirements and multiple source paths. As a fall-back, being able to say give a broader PYTHONPATH like --source-roots ="./published/python:./libraries/python/" would help.

Additional context

There's likely an extension of this ask to other build tools like bazel.

@JettJones JettJones added the enhancement New feature or request label Mar 18, 2024
@fpgmaas
Copy link
Owner

fpgmaas commented Mar 19, 2024

A solution that you could try today is using the known_first_party flag. This should resolve your DEP001 errors.

I wonder if the use case/ask for pointing to multiple roots is then still big enough. If so, I think it would make sense to first create a generic solution that is not specific to Pants. In this case, maybe an option would be to add include and extend-include flags, similar to ruff.

Then, if we want to support Pants.toml, we could read the dependencies and sources from that file, and have sources added to the include flag. On the other hand, I am also a bit cautious to add support for Pants.toml directly; It adds additional maintenance for a feature of which I am not sure it will be widely used. I guess that depends a bit on the amount of traction this issue gets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants