Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dollarlint.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ exclude = [
"package-lock.json",
"packages.lock.json",
"pnpm-lock.yaml",
# Python projects as the python-dependencies extractor tests and the dependencies scenario read them. SchemaStore's
# catalog points pyproject.toml at a schema on raw.githubusercontent.com, outside the allowed domains below; uv,
# Poetry and PDM validate these when they lock the fixtures.
"packages/extractors/python-dependencies/tests/fixtures/**/pyproject.toml",
"packages/renderers/graph/fixtures/python-workspace/**/pyproject.toml",
# Kubernetes manifests (Tetragon TracingPolicies, their CRDs, workloads, Helm values and kernel profiles) as the
# tetragon-policies extractor and its docs examples read them. Kubernetes schemas are per kind and per cluster
# version, and none is published for a mixed manifest; the extractor validates the policies against the CRDs.
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions changelog.d/386.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
section: built-ins
---

- **`python-dependencies` draws a Python project's dependency graph** (#386). The new built-in extractor reads `uv.lock`, `poetry.lock`, `pdm.lock` or pinned requirements files, with the projects `pyproject.toml` declares (PEP 621 `[project]`, Poetry and uv workspace members), straight from the revision's files: it runs no Python, installs nothing and needs no `--trust`. Projects and packages are drawn with the `dependencies` renderer like the npm, Cargo and NuGet graphs, direct and transitive dependencies come from the lockfile, and extras and dependency groups are relationships of their own; environment markers are recorded but not evaluated. `projections explore` proposes it for Python projects. See [Python dependencies](docs/builtins/extractors/python-dependencies.md).
1 change: 1 addition & 0 deletions docs/builtins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The VS Code extension also opens these pages when you select a built-in part.
| [`swift-package-dependencies`](extractors/swift-package-dependencies.md) | Swift package products, targets, target dependencies and package dependencies with Package.resolved versions. | `graph/v0` | [`dependencies`](renderers/graph.md) |
| [`xcode-modules`](extractors/xcode-modules.md) | Xcode targets with their module names, target and package product dependencies, and the modules their Swift sources import. | `graph/v0` | [`dependencies`](renderers/graph.md) |
| [`nuget-dependencies`](extractors/nuget-dependencies.md) | Resolved NuGet project.assets.json graph. | `graph/v0` | [`dependencies`](renderers/graph.md) |
| [`python-dependencies`](extractors/python-dependencies.md) | Python projects and the packages uv.lock, poetry.lock, pdm.lock or pinned requirements files resolve for them. | `graph/v0` | [`dependencies`](renderers/graph.md) |
| [`terraform-infrastructure`](extractors/terraform-infrastructure.md) | Terraform resources, modules and references, with each resource's planned action. | `architecture/v0` | [`infrastructure`](renderers/graph.md) |
| [`azure-what-if`](extractors/azure-what-if.md) | Azure resources, containment and references, with each resource's what-if change. | `architecture/v0` | [`infrastructure`](renderers/graph.md) |
| [`github-actions-jobs`](extractors/github-actions-jobs.md) | Triggers, jobs, needs and matrices declared by a GitHub Actions workflow. | `dag/v0` | [`github-actions`](renderers/github-actions.md) |
Expand Down
7 changes: 4 additions & 3 deletions docs/builtins/extractors/cargo-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ each crate.

- [`graph`](../renderers/graph.md) renders this extractor with its
`dependencies` presentation.
- [`workspace-dependencies`](workspace-dependencies.md) and
[`nuget-dependencies`](nuget-dependencies.md) provide the same dependency
graph for Node and .NET.
- [`workspace-dependencies`](workspace-dependencies.md),
[`nuget-dependencies`](nuget-dependencies.md) and
[`python-dependencies`](python-dependencies.md) provide the same dependency
graph for Node, .NET and Python.
- [`rust-public-api`](rust-public-api.md) tracks what a crate exports rather
than what it depends on.
- [The default comparator](../comparators/default.md) can order review steps by
Expand Down
7 changes: 4 additions & 3 deletions docs/builtins/extractors/nuget-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ each package.

- [`graph`](../renderers/graph.md) renders this extractor with its
`dependencies` presentation.
- [`workspace-dependencies`](workspace-dependencies.md) and
[`cargo-dependencies`](cargo-dependencies.md) provide the same dependency
graph for Node and Rust.
- [`workspace-dependencies`](workspace-dependencies.md),
[`cargo-dependencies`](cargo-dependencies.md) and
[`python-dependencies`](python-dependencies.md) provide the same dependency
graph for Node, Rust and Python.
- [`dotnet-public-api`](dotnet-public-api.md) and [`dotnet-di`](dotnet-di.md)
inspect what .NET projects export and wire up.
- [The default comparator](../comparators/default.md) can order review steps by
Expand Down
161 changes: 161 additions & 0 deletions docs/builtins/extractors/python-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Python dependencies

This extractor maps a Python project (or a uv workspace of them) and the full
transitive dependency tree behind it: what each project declares, what its
lockfile resolves that to, and what those packages pull in. Compared across a
pull request, it shows which dependencies were added, removed, upgraded, or
downgraded—and what pulls them in.

<!-- generated: facts -->

- ID: `python-dependencies`
- Extraction schema: [`graph/v0`](../../reference/schemas/graph.md)
- Drawn by default with: [`dependencies`](../renderers/graph.md)
- Needs `--trust`: No (`none`)
- Suggested when the repository has: `pyproject.toml`, `uv.lock`, `poetry.lock`,
`pdm.lock`, `requirements*.txt`, `requirements/*.txt`, `**/pyproject.toml`,
`**/uv.lock`, `**/poetry.lock`, `**/pdm.lock`

<!-- end generated: facts -->

## When to use it

Use this extractor in any Python repository that locks its dependencies with uv,
Poetry or PDM, or pins them in requirements files, when you want to review
dependency changes as a graph instead of wading through a lockfile diff. A new
direct dependency and the transitive packages it brings, a major bump deep in
the tree, or a dependency group growing a new tool all stand out immediately.

Because it only reads manifests and lockfiles, it runs safely on any pull
request without `--trust`, and needs no Python installation.

It covers Python packages only. For Node use
[`workspace-dependencies`](workspace-dependencies.md), for Rust use
[`cargo-dependencies`](cargo-dependencies.md), and for .NET use
[`nuget-dependencies`](nuget-dependencies.md).

## What it reads

- The root `pyproject.toml`: PEP 621 `[project]` dependencies and
`optional-dependencies`, PEP 735 `[dependency-groups]`, Poetry's
`[tool.poetry]` dependencies, groups and extras, and PDM's and uv's
development dependencies. For a uv workspace, every member
`[tool.uv.workspace]` selects.
- One lockfile: `uv.lock` (version 1), `poetry.lock` (lock-version 1.x or 2.x)
or `pdm.lock` (lock_version 4.x).
- Without a lockfile, pinned requirements files: `requirements*.txt` and
`requirements/*.txt`, with the files they include. `# via` annotations written
by `pip-compile` or `uv pip compile` say what pulls each pin in.

The manager is chosen from `inputs.manager`, then the lockfile present (or, with
several, the manager the root `pyproject.toml` configures), then requirements
files. Nothing is installed or executed.

Each project becomes a `project` entity, and each package it reaches a `package`
with its `version`. Declared dependencies become typed edges—`dependencies`, an
extra's `optionalDependencies`, a group's `devDependencies`—recording the
declared specifier and the resolved version. Because entity IDs exclude
versions, an upgrade appears as a single modified package rather than a removal
and an addition.

## Options

<!-- generated: inputs -->

| Input | Meaning |
| -------------- | --------------------------------------------------------------------------------------------------- |
| `manager` | uv, poetry, pdm or requirements; default from the lockfile present. |
| `requirements` | Array of requirements files relative to the root; default requirements*.txt and requirements/*.txt. |
| `root` | Repository-relative project or workspace root; default ".". |

<!-- end generated: inputs -->

## What a comparison shows

- **Added or removed packages** — a new dependency with everything it pulls in,
or a package that is no longer locked.
- **Upgrades and downgrades** shown as modified packages. The
[`dependencies`](../renderers/graph.md) renderer labels each by which version
component moved (`Major upgrade`, `Patch downgrade`), and the summary bar
groups them into clickable filters, plus how many direct dependencies changed.
- **Declaration changes**, such as moving a dependency into a dependency group,
adding an extra, or widening a specifier from `>=1.2` to `>=1.3`.

Unchanged transitive dependencies collapse into summary cards ("12 more
packages") to keep the diff focused; toggle **All packages** to expand them.

## Start from this definition

<!-- generated: definition -->

```json
{
"extractor": "python-dependencies",
"id": "python-dependencies",
"renderer": "dependencies",
"title": "Python dependencies"
}
```

<!-- end generated: definition -->

## Limitations

- Environment markers are recorded on each relationship but not evaluated: the
graph is the lockfile's resolution for every platform and Python version at
once.
- Every extra and dependency group a project declares is included; a package's
own extras are followed only where something in the graph requests them.
- Requirements files record no dependency graph: without `# via` annotations
every pin is a direct dependency, and lines that don't pin one version with
`==` (ranges, URLs, editable installs) are left out and listed in
`metadata.skipped`.
- `poetry.lock` and `pdm.lock` don't record which of several locked copies of a
name a dependency uses, so a dependency on such a name points at every copy.
- Poetry and PDM path dependencies are packages, not projects; only uv
workspaces have several projects.
- Because it reads lockfiles rather than querying an index, it doesn't include
vulnerability data, licenses, or package contents.

## Related

- [`graph`](../renderers/graph.md) — draws this graph using its `dependencies`
presentation.
- [`workspace-dependencies`](workspace-dependencies.md),
[`cargo-dependencies`](cargo-dependencies.md) and
[`nuget-dependencies`](nuget-dependencies.md) — the same dependency graph for
Node, Rust and .NET.
- [`django-schema`](django-schema.md) — a Django project's models.

## How it works

See the
[package README](../../../packages/extractors/python-dependencies/README.md) for
each lockfile's reading rules and the extraction model.

## Build your own

Consider writing a custom extractor when lockfiles don't capture what you need:

- **Other tools or layouts**, such as Pipenv's `Pipfile.lock`, Conda
environments, or Pants and Bazel build graphs.
- **One environment**, evaluating markers for a single platform and Python
version.
- **Module-level granularity**, tracking imports between source files instead of
packages.

Check the built-in options first: `root` points at a nested project, `manager`
picks one lockfile of several, and `requirements` selects requirements files. To
visualize the same graph differently, keep this extractor and write a custom
renderer.

**With the CLI**, keep this graph's renderer:

```sh
projections init <id> --language python --renderer dependencies
```

[Write your first extractor](../../guides/first-extractor.md) walks through a
complete example, and
[Extraction schema](../../guides/schemas.md#extraction-schema) documents the
output format.
7 changes: 4 additions & 3 deletions docs/builtins/extractors/workspace-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ packages") to keep the diff focused; toggle **All packages** to expand them.

- [`graph`](../renderers/graph.md) — draws this graph using its `dependencies`
presentation.
- [`cargo-dependencies`](cargo-dependencies.md) and
[`nuget-dependencies`](nuget-dependencies.md) — the same dependency graph for
Rust and .NET.
- [`cargo-dependencies`](cargo-dependencies.md),
[`nuget-dependencies`](nuget-dependencies.md) and
[`python-dependencies`](python-dependencies.md) — the same dependency graph
for Rust, .NET and Python.
- [The default comparator](../comparators/default.md) — supports ordering steps
by dependent count (`order.by: dependents`).

Expand Down
7 changes: 5 additions & 2 deletions docs/builtins/renderers/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Built-in extractors that use it by default:
| [`swift-package-dependencies`](../extractors/swift-package-dependencies.md) | `dependencies` |
| [`xcode-modules`](../extractors/xcode-modules.md) | `dependencies` |
| [`nuget-dependencies`](../extractors/nuget-dependencies.md) | `dependencies` |
| [`python-dependencies`](../extractors/python-dependencies.md) | `dependencies` |
| [`terraform-infrastructure`](../extractors/terraform-infrastructure.md) | `infrastructure` |
| [`azure-what-if`](../extractors/azure-what-if.md) | `infrastructure` |
| [`openrewrite-data-tables`](../extractors/openrewrite-data-tables.md) | `architecture` |
Expand Down Expand Up @@ -392,8 +393,10 @@ inside the `invoicing` module along with its new dependencies.

- Default extractors:
[`workspace-dependencies`](../extractors/workspace-dependencies.md),
[`cargo-dependencies`](../extractors/cargo-dependencies.md), and
[`nuget-dependencies`](../extractors/nuget-dependencies.md) (`dependencies`);
[`cargo-dependencies`](../extractors/cargo-dependencies.md),
[`nuget-dependencies`](../extractors/nuget-dependencies.md), and
[`python-dependencies`](../extractors/python-dependencies.md)
(`dependencies`);
[`terraform-infrastructure`](../extractors/terraform-infrastructure.md) and
[`azure-what-if`](../extractors/azure-what-if.md) (`infrastructure`);
[`github-actions-jobs`](../extractors/github-actions-jobs.md) (`dag`); and
Expand Down
26 changes: 26 additions & 0 deletions docs/reference/extractors.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ it was removed) isn't an error: the extractor describes that revision without it
| [`swift-package-dependencies`](#swift-package-dependencies) | `graph/v0` | `dependencies` | When it runs ecosystem tools or repository code (`when-executing-tools`) |
| [`xcode-modules`](#xcode-modules) | `graph/v0` | `dependencies` | No (`none`) |
| [`nuget-dependencies`](#nuget-dependencies) | `graph/v0` | `dependencies` | When it runs ecosystem tools or repository code (`when-executing-tools`) |
| [`python-dependencies`](#python-dependencies) | `graph/v0` | `dependencies` | No (`none`) |
| [`terraform-infrastructure`](#terraform-infrastructure) | `architecture/v0` | `infrastructure` | When it runs ecosystem tools or repository code (`when-executing-tools`) |
| [`azure-what-if`](#azure-what-if) | `architecture/v0` | `infrastructure` | When it runs ecosystem tools or repository code (`when-executing-tools`) |
| [`github-actions-jobs`](#github-actions-jobs) | `dag/v0` | `github-actions` | No (`none`) |
Expand Down Expand Up @@ -343,6 +344,31 @@ A definition to start from:
}
```

## `python-dependencies`

**Python dependencies.** Python projects and the packages uv.lock, poetry.lock, pdm.lock or pinned requirements files resolve for them. See [its page](../builtins/extractors/python-dependencies.md).

- Schema: `graph/v0`
- Default renderer: `dependencies`
- Needs `--trust`: No (`none`)

| Input | Meaning |
|---|---|
| `manager` | uv, poetry, pdm or requirements; default from the lockfile present. |
| `requirements` | Array of requirements files relative to the root; default requirements*.txt and requirements/*.txt. |
| `root` | Repository-relative project or workspace root; default ".". |

A definition to start from:

```json
{
"extractor": "python-dependencies",
"id": "python-dependencies",
"renderer": "dependencies",
"title": "Python dependencies"
}
```

## `terraform-infrastructure`

**Terraform infrastructure.** Terraform resources, modules and references, with each resource's planned action. See [its page](../builtins/extractors/terraform-infrastructure.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/renderers.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Built-in Projections graph renderer: staged, identity-stable graph transitions (
- Handles: `graph`, `graph-horizontal`, `dag`, `architecture`, `infrastructure`, `dependencies`
- Comparison modes: `diff`, `side-by-side`, `animated`, `swipe`
- Package: `@githubnext/projections-renderer-graph`
- Example scenarios ([`scenarios.json`](../../packages/renderers/graph/scenarios.json)): Service platform; Service platform, payments first (custom order); Test timings with volatile durations; Class summaries, generated by a model; Source references, left to right; Declared rename; Feature flags; Feature flags, one revision; Single extraction; CI pipeline restructure; Release workflow; Platform gains a worker; Storage module split; Single extraction; Card icons; OpenRewrite: JUnit 4 to JUnit 5; Terraform: the database is replaced; Bicep: a private endpoint subnet; Terraform: one revision's plan; React 19.2 and clsx; Express 5 and React 19; npm workspace (one revision); NuGet package update; NuGet library with long package names; A layered module graph; A layered module graph (one revision); A wide module graph; A wide module graph (one revision); A hub-heavy module graph (one revision); MCP tools, toolsets and OAuth scopes; An architecture of 42 components (one revision); Who may reach what: 6 callers, 16 owners, 74 relationships (graph); Who may reach what: 6 callers, 16 owners, 74 relationships (architecture)
- Example scenarios ([`scenarios.json`](../../packages/renderers/graph/scenarios.json)): Service platform; Service platform, payments first (custom order); Test timings with volatile durations; Class summaries, generated by a model; Source references, left to right; Declared rename; Feature flags; Feature flags, one revision; Single extraction; CI pipeline restructure; Release workflow; Platform gains a worker; Storage module split; Single extraction; Card icons; OpenRewrite: JUnit 4 to JUnit 5; Terraform: the database is replaced; Bicep: a private endpoint subnet; Terraform: one revision's plan; React 19.2 and clsx; Express 5 and React 19; npm workspace (one revision); NuGet package update; NuGet library with long package names; Python uv workspace: a year of releases; A layered module graph; A layered module graph (one revision); A wide module graph; A wide module graph (one revision); A hub-heavy module graph (one revision); MCP tools, toolsets and OAuth scopes; An architecture of 42 components (one revision); Who may reach what: 6 callers, 16 owners, 74 relationships (graph); Who may reach what: 6 callers, 16 owners, 74 relationships (architecture)

## `runtime-policy`

Expand Down
Loading
Loading