Repository navigation
python-dependencies: a built-in extractor for Python projects - #386
Open
agorischek wants to merge 7 commits into
Open
agorischek wants to merge 7 commits into
agorischek wants to merge 7 commits into
Conversation
Reads uv.lock, poetry.lock, pdm.lock and pinned requirements files with the projects pyproject.toml declares (PEP 621, Poetry, uv workspaces), and draws them with the dependencies renderer. explore proposes it for Python projects. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…'s style Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved extraction errors can drop or misattribute dependency relationships, reject valid dependency-group references, and hide locked Git revision updates.
8 open issues
Keep IDs unique for distinct dependency conditions · New Include PDM's locked Git revision in package data · New Include Poetry's resolved Git commit in package data · New Match requirement pins and annotations by package version · New Process inline pip-compile dependency annotations · New Use dependency sources to select locked package copies · New Preserve separate constraints for conditional dependencies · New Normalize names when resolving dependency group references · New
What changed in this PR
Adds a file-only Python dependency extractor to Projections, using the existing dependencies presentation without requiring Python, installs, or trust.
Changes:
- Reads uv, Poetry, PDM, and pinned requirements files into dependency graphs.
- Registers the extractor and adds discovery for root and nested Python projects.
- Adds fixtures, tests, documentation, and a changelog entry.
| File | Description |
|---|---|
| packages/renderers/graph/README.md | Documents Python dependency graphs. |
| packages/extractors/README.md | Lists runtime requirements. |
| packages/extractors/python-dependencies/tests/lockfiles.rs | Adds extraction integration tests. |
| packages/extractors/python-dependencies/tests/fixtures/uv-workspace/uv.lock | Supplies locked workspace dependencies. |
| packages/extractors/python-dependencies/tests/fixtures/uv-workspace/pyproject.toml | Defines workspace fixture. |
| packages/extractors/python-dependencies/tests/fixtures/uv-workspace/packages/legacy/pyproject.toml | Exercises member exclusion. |
| packages/extractors/python-dependencies/tests/fixtures/uv-workspace/packages/core/src/harbor_core/__init__.py | Supplies fixture package structure. |
| packages/extractors/python-dependencies/tests/fixtures/uv-workspace/packages/core/pyproject.toml | Defines core workspace member. |
| packages/extractors/python-dependencies/tests/fixtures/uv-workspace/packages/api/src/harbor_api/__init__.py | Supplies fixture package structure. |
| packages/extractors/python-dependencies/tests/fixtures/uv-workspace/packages/api/pyproject.toml | Defines API member and extras. |
| packages/extractors/python-dependencies/tests/fixtures/requirements/requirements.txt | Supplies annotated dependency pins. |
| packages/extractors/python-dependencies/tests/fixtures/requirements/requirements.in | Defines compilation inputs. |
| packages/extractors/python-dependencies/tests/fixtures/requirements/requirements-dev.txt | Exercises includes and skipped requirements. |
| packages/extractors/python-dependencies/tests/fixtures/requirements.expected.json | Records expected requirements graph. |
| packages/extractors/python-dependencies/tests/fixtures/poetry/pyproject.toml | Defines Poetry fixture. |
| packages/extractors/python-dependencies/tests/fixtures/poetry.expected.json | Records expected Poetry graph. |
| packages/extractors/python-dependencies/tests/fixtures/pdm/pyproject.toml | Defines PDM fixture. |
| packages/extractors/python-dependencies/tests/fixtures/pdm/pdm.lock | Supplies locked PDM dependencies. |
| packages/extractors/python-dependencies/tests/fixtures/pdm.expected.json | Records expected PDM graph. |
| packages/extractors/python-dependencies/tests/fixtures/lock.mjs | Regenerates fixture lockfiles. |
| packages/extractors/python-dependencies/src/requirement.rs | Parses names and requirements. |
| packages/extractors/python-dependencies/src/pyproject.rs | Reads projects, extras, and groups. |
| packages/extractors/python-dependencies/src/model.rs | Defines shared dependency models. |
| packages/extractors/python-dependencies/src/lockfile/uv.rs | Parses uv lockfiles. |
| packages/extractors/python-dependencies/src/lockfile/requirements.rs | Parses pins, includes, and annotations. |
| packages/extractors/python-dependencies/src/lockfile/poetry.rs | Parses Poetry lockfiles. |
| packages/extractors/python-dependencies/src/lockfile/pdm.rs | Parses PDM lockfiles. |
| packages/extractors/python-dependencies/src/lockfile.rs | Provides shared parsing helpers. |
| packages/extractors/python-dependencies/src/lib.rs | Coordinates detection and extraction. |
| packages/extractors/python-dependencies/src/graph.rs | Builds graph entities and relationships. |
| packages/extractors/python-dependencies/README.md | Documents inputs and extraction semantics. |
| packages/extractors/python-dependencies/Cargo.toml | Defines extractor crate. |
| packages/extractors/catalog/src/lib.rs | Registers the extractor. |
| packages/extractors/catalog/Cargo.toml | Adds catalog dependency. |
| packages/cli/tests/first_party.rs | Adds first-party extraction case. |
| packages/cli/test/cli.test.mjs | Updates expected catalog entries. |
| packages/cli/src/explore/python.rs | Proposes nested Python projects. |
| packages/cli/src/explore.rs | Integrates Python discovery. |
| docs/reference/extractors.md | Adds extractor reference entry. |
| docs/builtins/renderers/graph.md | Lists Python renderer integration. |
| docs/builtins/README.md | Adds built-in catalog entry. |
| docs/builtins/extractors/workspace-dependencies.md | Cross-links Python support. |
| docs/builtins/extractors/python-dependencies.md | Adds usage and limitations guide. |
| docs/builtins/extractors/nuget-dependencies.md | Cross-links Python support. |
| docs/builtins/extractors/cargo-dependencies.md | Cross-links Python support. |
| changelog.d/386.md | Announces Python dependency extraction. |
| Cargo.lock | Records the new crate dependency. |
Review effort: Balanced
Two revisions of a uv workspace, locked a year apart and read by python-dependencies: python-workspace-2025.json and -2026.json, named by year so the rules comparator's golden corpus doesn't pair them. Registered as the python-uv-workspace scenario and added to the dependency-graph tests; like the npm major upgrade, its routes are checked for crossings at rest and at each step's hold. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…t of graph.rs graph.rs was over the repository's complexity limit (considered: 75, max 60). Version ordering moves to version.rs and package identities to graph/identity.rs, unchanged. Also fixes two clippy warnings (a redundant closure, and a complex key type now named). Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…ollarLint's schema fetch The scenario's uv lockfiles are kept as uv.lock.fixture and copied in as uv.lock by make-python.mjs: GitHub's dependency graph reads every uv.lock, and the 2025 revision deliberately locks releases with since-published advisories (anyio < 4.14.2), which failed dependency review and would raise Dependabot alerts for packages nothing installs. The extractions are unchanged. DollarLint excludes the fixture pyproject.toml files, as it does other third-party formats the extractor tests read: SchemaStore's catalog points pyproject.toml at raw.githubusercontent.com, outside the allowed domains. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…and group names - Relationship IDs stay unique when one dependency is declared under several markers that resolve to one package: identical declarations are one, and conditions on one target add their marker instead of overwriting each other. - uv dependency entries' `source` selects the copy they mean, so two copies of one name and version from different sources aren't both targeted. - A uv member's declared specifier is matched by the locked edge's marker, so a name required under several markers keeps each specifier. - Requirements files keep every copy of a name pinned under exclusive markers, and `# via` names pull in every copy; inline `# via` annotations (`--annotation-style=line`) count. - Poetry's `resolved_reference` and PDM's `revision` are part of a Git package's source, so moving to another commit is a change. - PEP 735 `include-group` compares normalized group names. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
4 tasks done
This branch has not been deployed
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.

What changed
A new built-in extractor,
python-dependencies, draws a Python project's dependency graph with the samedependenciesrenderer and presentation asworkspace-dependencies,cargo-dependenciesandnuget-dependencies(so it picks up #343's churn folding when that lands). Until nowexploreproposed nothing Python-specific for Python libraries and applications; the only Python built-in wasdjango-schema.It reads the revision's files only — no Python, no installs, no
--trust:uv.lock(version 1),poetry.lock(lock-version 1.x and 2.x),pdm.lock(4.x), and pinned requirements files (requirements*.txt,requirements/*.txt, following-r), wherename==versionlines are pinned packages.pyproject.toml— PEP 621[project](dependencies,optional-dependencies), PEP 735[dependency-groups]withinclude-group, Poetry's[tool.poetry]dependencies, groups and extras, PDM's and uv's development dependencies, and uv workspace members ([tool.uv.workspace]members/exclude). uv members' declarations come from whatuv.lockrecorded for them.project(project:<name>) andpackage(package:<name>, PEP 503-normalized; versions are data, so an upgrade is one modified package; several locked copies of one name get@<line>suffixes, asworkspace-dependenciesdoes).pip-compile/uv pip compile# viaannotations, where present, say what pulls each pin in.httpx[http2]addsh2). Markers are recorded on relationships asdata.marker, not evaluated.metadata.limitations: markers aren't evaluated (the graph covers every platform and Python version); every project extra and group is included; requirements files have no graph without# via, and unpinned lines (ranges, URLs,-e) are dropped and listed inmetadata.skipped; Poetry/PDM don't say which of several copies of a name a dependency uses, so it points at each; without a lockfile, declarations keep their ranges with no resolution.exploreproposes it aspython-dependencieswhen the root has apyproject.toml, lockfile or requirements files, mirroring the cargo and npm candidates; when Python projects live only in subdirectories, it proposes each top-most one withinputs.root(at most 8).Also: the extractor README, a docs page (
docs/builtins/extractors/python-dependencies.md), catalog registration, the extractors reference and built-ins tables, and cross-links from the other dependency built-ins.A
dependenciesrenderer scenario,python-uv-workspace("Python uv workspace: a year of releases"), beside the npm and NuGet ones: two revisions of a three-project uv workspace (packages/renderers/graph/fixtures/python-workspace/), locked a year apart and read bypython-dependenciesintopython-workspace-2025.jsonandpython-workspace-2026.json. The files are named by year, not-v1/-v2, so the rules comparator's golden corpus doesn't pick them up as a pair.fixtures/make-python.mjsregenerates them. The lockfiles are committed asuv.lock.fixtureand copied in asuv.lock, because GitHub's dependency graph reads everyuv.lockand the 2025 lock deliberately holds releases with since-published advisories (dependency review failed on anyio < 4.14.2). The pair joins the dependency-graph tests (primary paths, every change visible, no route through a card). Like the npm major upgrade, its crossing check runs at rest and at each step's hold, not mid-step: at 0.82 of the transition one route (pytest → exceptiongroup) brushes the packaging card while cards make room.Review fixes: relationship IDs stay unique when one dependency is declared under several markers. uv dependency entries'
sourceselects the copy they mean, and a member's specifier is matched by the edge's marker. Requirements files keep every copy of a name pinned under exclusive markers and read inline# viaannotations. Poetry'sresolved_referenceand PDM'srevisionare part of a Git package'ssource.include-groupcompares normalized names. Each fix has a test that fails without it. The scenario fixtures, golden extractions and the fastapi comparison are unchanged.Housekeeping:
graph.rswas over the repository's complexity limit (considered: 75, max 60), so PEP 440 ordering moved toversion.rsand package identities tograph/identity.rs, unchanged. Two clippy warnings are fixed. DollarLint excludes the fixturepyproject.tomlfiles, as it does other third-party formats extractor tests read, because SchemaStore's catalog pointspyproject.tomlat a schema onraw.githubusercontent.com, outside the allowed domains.Trial: fastapi/fastapi#16849
projections compare cf65d62e..cbedbf8b -p python-dependencies --pngon a fastapi/fastapi clone (the 24-bump dependency PR).exploreproposespython-dependenciesfirst, and the comparison runs without adopting it. Result: one project, 167 locked packages, 31 upgraded or downgraded,logfire-cliadded (logfire 6 depends on it),pyeeremoved (playwright 1.65 drops it), and 134 unchanged packages hidden. Each changed package keeps the path that pulls it in. The bumped direct dependencies sit on the project's edges, and transitive changes (the opentelemetry exporters, deepmerge, httpcore2, pydantic-core) show beside them.Evidence
cargo test -p projections-extractor-python-dependenciespassed (14 unit, 12 integration). The uv (multi-project workspace), Poetry, PDM and requirements-file fixtures were locked by uv, Poetry and PDM themselves (tests/fixtures/lock.mjs), and golden extractions compare each one.cargo test -p projections-cli --test first_partypassed (1, including the newpython-dependenciescase).node --test packages/cli/test/cli.test.mjspassed (7/7) against a debug build.cargo test -p projections-cli --lib explorepassed (34), including the new nested-project proposals.node --test packages/renderers/graph/test/dependencies.test.mjspassed (14), andtools test packages/renderers/graphpassed (50).npm run docs:generate -- --only builtins,extractors,cli,renderers,agents: the hand-filled built-in doc regions were already current. Onlydocs/reference/renderers.mdchanged, to list the new scenario.tools check --fastpassed (considered, clippy, format, lint, typecheck of what changed). Undertools check --affected, cargo-check, clippy, considered, notices, comparators, boundaries and links pass. Its build, typecheck and lint gates failed here only on the VS Code extension's unbuilthost-vscodedependency, which this change doesn't touch.The scenario's 2025 lock is resolved against pypi.org's index, as
make-python.mjsdoes by default.uv lockonly reads metadata and installs nothing. The package feed proxy can't serve--exclude-newer, because its simple index reports each file's upload time as when the proxy cached it (all 2026), so no release appears to predate 2025-03-01.Documentation that this change affects is updated, and generated reference
pages are regenerated (
npm run docs:generate).Fixes include a regression test.
A changelog fragment at
changelog.d/<this PR's number>.mddescribes whatusers will notice, or the PR has the
no changeloglabel (seechangelog.d/README.md).
No credentials, private source or machine-specific paths are included.