Treat all packages listed in requirements.txt as direct dependencies#7320
Merged
Jenson3210 merged 4 commits intomainfrom Apr 8, 2026
Merged
Treat all packages listed in requirements.txt as direct dependencies#7320Jenson3210 merged 4 commits intomainfrom
Jenson3210 merged 4 commits intomainfrom
Conversation
Previously, `dependenciesFromResolved()` only treated graph-root packages (those not depended on by any other installed package) as direct. This caused packages like `aiohttp`, `cryptography`, `Jinja2` etc. to be classified as transitive when they were explicitly pinned in the requirements.txt but also happened to be dependencies of other listed packages. As a result, vulnerability fix recipes skipped upgrading them. Now, the parser scans the requirements.txt file content and passes the declared package names to `dependenciesFromResolved()`, ensuring every explicitly listed package is treated as a direct dependency regardless of the dependency graph. Fixes moderneinc/customer-requests#2157
Verifies that packages listed in requirements.txt are treated as direct while packages only present in the freeze output (true transitives) are excluded from the dependencies list.
timtebeek
approved these changes
Apr 8, 2026
Jenson3210
commented
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where packages explicitly listed in
requirements.txtwere classified as transitive (and skipped by vulnerability fix recipes) when they also appeared as dependencies of other installed packagesAdds
parseDeclaredPackageNames()to extract package names from the file content, and passes them todependenciesFromResolved()so they are always treated as directThe existing root-only behavior is preserved for
setup.cfg/setup.pycallers via the original no-arg overloadFixes moderneinc/customer-requests#2157
Test plan
dependenciesFromResolvedExcludesTransitives— existing behavior preserved when no declared names provideddependenciesFromResolvedTreatsDeclaredPackagesAsDirect— new test verifying declared packages remain direct even when they appear as transitive depsparseDeclaredPackageNamesExtractsNames— new test verifying name extraction from various requirement line formatsRequirementsTxtParserTesttests pass