Python: Extend dependency recipes with scope support and package-manager-aware transitive pinning#6715
Merged
knutwannheden merged 4 commits intomainfrom Feb 11, 2026
Merged
Conversation
Extend AddDependency, RemoveDependency, and UpgradeDependencyVersion with scope and groupName options to target project.optional-dependencies and dependency-groups in addition to project.dependencies. Generalize PyProjectHelper with isInsideDependencyArray and findDependencyInScope. Rename DependencyInsight scope values to TOML dotted-path convention (e.g. "buildRequires" -> "build-system.requires"). Add ChangeDependency recipe that renames a package across all dependency arrays in pyproject.toml, optionally setting a new version.
…ersion Add constraintDependencies and overrideDependencies fields to PythonResolutionResult for uv constraint-dependencies and override-dependencies sections. Extract these from pyproject.toml via PythonDependencyParser and link to resolved deps. Extend all dependency recipes (Add, Remove, Upgrade, DependencyInsight) with tool.uv.constraint-dependencies and tool.uv.override-dependencies scope values. Introduce UpgradeTransitiveDependencyVersion recipe that pins a transitive dependency by adding or upgrading a constraint in the [tool.uv].constraint-dependencies array.
613fdc6 to
f43e7dd
Compare
Add pdmOverrides field to PythonResolutionResult and detect package manager from pyproject.toml table names (tool.uv → Uv, tool.pdm → Pdm). UpgradeTransitiveDependencyVersion now branches by package manager: uv uses constraint-dependencies, PDM uses tool.pdm.overrides, and unknown managers fall back to adding a direct dependency.
f43e7dd to
a642fbd
Compare
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
scopeandgroupNameoptions toAddDependency,RemoveDependency, andUpgradeDependencyVersionso they can targetproject.optional-dependencies,dependency-groups,tool.uv.constraint-dependencies,tool.uv.override-dependencies, andtool.pdm.overridesin addition toproject.dependenciesChangeDependencyrecipe to rename packages (with optional version change) across all dependency scopesUpgradeTransitiveDependencyVersionrecipe that pins transitive dependencies using the appropriate strategy per package manager: uv usesconstraint-dependencies, PDM usestool.pdm.overrides, unknown managers fall back to adding a direct dependencyconstraintDependenciesandoverrideDependenciesfields toPythonResolutionResultmarker (overrideDependenciesis shared by uv and PDM, disambiguated by thePackageManagerenum), with package manager detection frompyproject.tomltable namesTest plan
AddDependencyTest— new tests for optional-dependencies, dependency-groups, constraint-dependencies scopesRemoveDependencyTest— new tests for optional-dependencies, dependency-groups, override-dependencies scopesUpgradeDependencyVersionTest— new tests for optional-dependencies, dependency-groups, constraint-dependencies scopesChangeDependencyTest— rename, rename with version, preserve extras/markers, skip when not found, rename across scopesUpgradeTransitiveDependencyVersionTest— uv constraint add/upgrade/skip tests, PDM override add/upgrade/skip tests, unknown manager fallback testsDependencyInsightTest— updated scope naming, constraint/override/pdm scope coveragePythonResolutionResultTest— updated constructor calls for new fields