Add diff aware filtering to `analyze graph`
- Dominant language
- Rust
- Stars
- 49.7k
- Forks
- 2.4k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 458
Description
This may be a post-`red-knot` issue (or even a `uv` issue), so happy to relocate this as needed.
One of the really powerful features which `pants` offers is the ability to [leverage its dependency](https://www.pantsbuild.org/dev/docs/using-pants/advanced-target-selection#running-over-changed-files-with---changed-since) graph to only run tests/linting on files which are directly or indirectly impacted by changes. The multi-file (and presumably multi-package) analysis of red-knot plus the projects api of `uv` means that a lot of the components required to support this behaviour are being developed or are in place already.
Copying pants' api for an example syntax:
```
ruff analyze graph --changed-since=origin/main --changed-dependents=transitive .
ruff check --changed-since=HEAD
```
Given how fast `ruff` is, this might seem unnecessary, but the real value here comes from being able to then leverage this using other tools like `pytest` to only run tests which are impacted by your changes.
Another point I'd note here is that `pants` does the dependency graph at the file level, but `red-knot` could enable this down to the function level to allow even more granular test selection.
Contributor guide
Research direction
Start with the `ruff analyze graph` entry point and compare its proposed `--changed-since` and `--changed-dependents` behavior with Pants' changed-file API. Review how red-knot and the uv projects API expose dependency information. Done means graph analysis and commands such as `ruff check` can select directly or transitively impacted files for downstream tools like pytest.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- cli, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100