-
Notifications
You must be signed in to change notification settings - Fork 22
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
Skip searching the pyproject.toml
for dependencies if requirements-files is explicitly passed
#1034
Conversation
…licitly set by the user
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1034 +/- ##
=====================================
Coverage 93.0% 93.1%
=====================================
Files 37 37
Lines 994 1000 +6
Branches 99 101 +2
=====================================
+ Hits 925 931 +6
Misses 55 55
Partials 14 14 ☔ View full report in Codecov by Sentry. |
@@ -41,6 +43,15 @@ class DependencyGetterBuilder: | |||
def build(self) -> DependencyGetter: | |||
pyproject_toml_found = self._project_contains_pyproject_toml() | |||
|
|||
if not self.using_default_requirements_files: | |||
if not self._any_requirements_files_exists(): | |||
raise FileNotFoundError( # noqa: TRY003 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added noqa
here. Alternative of creating a class called RequirementsFilesSpecifiedExplicitlyButNotFound
feels a bit superfluous 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if it wouldn't be cleaner to expose a --package-manager <name>
argument on the CLI to be able to enforce a specific manager if needed. This would have the benefit of being more generic, as it could solve the issue for any package manager.
I think that also makes sense! The main reason I chose the approach in this PR is that as a user I'd find it counterintuitive that if I pass Given the fact that it probably very rarely happens though, I agree a |
…licitly set by the user
PR Checklist
docs
is updatedDescription of changes
Currently, we search for dependencies in the following order:
However, this causes issues for users who have a
pyproject.toml
with a valid configuration, but still want to use the requirements.txt file for their dependency scanning bydeptry
. At the same time, it is a bit strange thatdeptry
searches thepyproject.toml
for dependencies, even if the user explicitly passed therequirements-files
parameter.We could solve both issues by skipping the search for dependencies in
pyproject.toml
when the user specifiesrequirements-files
explicitly.