Python repo graph builder with AST parsing, SCC, centrality, graph diffing, dead-code candidates, JSON, and Mermaid export.
Project description
repo-graph-kit
A small Python-first repo graph package.
It parses Python repositories with ast, builds a directed graph of modules, imports, classes, functions, methods, and calls, then exports the result as JSON or Mermaid.
Features
- Python AST repo graph builder
- Modules, imports, classes, functions, methods, inheritance, and calls
- Better local symbol and import alias call resolution
- DFS traversal
- BFS shortest path
- Strongly Connected Components using Tarjan's algorithm
- Topological sort for dependency ordering
- Degree centrality for blast-radius and hotspot detection
- Graph diffing for CI and PR tracking
- Dead-code candidate detection
- JSON export
- Mermaid export
- CLI command:
repo-graph
Install locally
pip install -e .
Publish to PyPI
This project is ready for standard PyPI packaging:
- build backend:
setuptools - package layout:
src/ - CLI entry point:
repo-graph
To release a version:
- Update
versioninpyproject.toml. - Install release tools with
python -m pip install --upgrade build twine. - Build distributions with
python -m build. - Verify them with
python -m twine check dist/*. - Upload to TestPyPI first, then to PyPI.
For automated releases, configure PyPI Trusted Publishing and use the GitHub Actions workflow in .github/workflows/publish.yml.
Build a graph
repo-graph scan ./examples/sample_project \
--json out/repo-graph.json \
--mermaid out/repo-graph.mmd \
--findings out/findings.json \
--metrics out/metrics.json
Diff two graphs
repo-graph diff previous/repo-graph.json current/repo-graph.json \
--json out/graph-diff.json
Python API
from repo_graph_kit import build_python_repo_graph
from repo_graph_kit.algorithms import (
strongly_connected_components,
top_central_nodes,
diff_graphs,
)
graph = build_python_repo_graph("examples/sample_project")
print(len(graph.nodes))
print(len(graph.edges))
print(strongly_connected_components(graph, edge_types={"imports"}))
print(top_central_nodes(graph, limit=5, edge_types={"imports", "calls"}))
Current limitations
This is intentionally static-analysis-first. It will not perfectly resolve dynamic imports, monkey patching, dependency injection, framework magic, or runtime-generated calls.
Treat findings like dead-code candidates as review hints, not automatic deletion instructions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file repo_graph_kit-0.2.0.tar.gz.
File metadata
- Download URL: repo_graph_kit-0.2.0.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2973b63162888af037a4a640384009315195edfdbd4e572899578000e22a584b
|
|
| MD5 |
58de6ef533d57787ef718feb7a4b418d
|
|
| BLAKE2b-256 |
fe6eb0ee274e018c9c58e4474ab20a487ffa73acfdde6692f3dd3d3a906b63b8
|
File details
Details for the file repo_graph_kit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: repo_graph_kit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4c503fb7ba98be650aef643ecb2f8504ccf4e06acfea23195568b48ad30af58
|
|
| MD5 |
a9e7c85b59219cc0182bf7ac2f1a39df
|
|
| BLAKE2b-256 |
04e97f13baffddaa1f0af876d0877de1313b38dfcbac7cf026412dcf40b58522
|