Quickstart
codeanalyzer-python points at a Python project and produces one typed artifact — its symbol table, call graph, and framework entrypoints. Three steps below: install, run it against a project, and read the result.
-
Install the CLI.
Terminal window pip install codeanalyzer-pythonThat installs the
codeanalyzercommand. Jedi and Tree-sitter ship with the package; CodeQL is downloaded on demand only if you opt in with--codeql. -
Run it against a project.
Point
--inputat any Python project root and--outputat a directory for the result.Terminal window codeanalyzer --input ./my-python-project --output ./outOn the first run codeanalyzer creates a virtual environment under
.codeanalyzer/, installs the project’s dependencies into it, walks every.pyfile, and writes./out/analysis.json. -
Read the result.
analysis.jsonis a singlePyApplicationobject with three top-level keys.Terminal window jq 'keys' ./out/analysis.json# [ "call_graph", "entrypoints", "symbol_table" ]jq '.symbol_table | length' ./out/analysis.json # modules analyzedjq '.call_graph | length' ./out/analysis.json # call edgesThat’s it — a directory of source files is now a typed, queryable model of the program.
Load it into a graph
Section titled “Load it into a graph”The call graph is a flat list of source -> target edges keyed by callable signature, so it drops straight into networkx:
import jsonimport networkx as nx
app = json.load(open("./out/analysis.json"))
g = nx.DiGraph()for edge in app["call_graph"]: g.add_edge(edge["source"], edge["target"])
print(g.number_of_nodes(), "nodes,", g.number_of_edges(), "edges")# Is a sink reachable from an entrypoint? A graph query, not a guess.# print(nx.has_path(g, entry_sig, sink_sig))Go deeper with CodeQL
Section titled “Go deeper with CodeQL”The default run uses Jedi for resolution — fast, no external tooling. Add --codeql to resolve the edges lexical analysis misses (dynamic dispatch, RPC, third-party targets). The CodeQL CLI is downloaded into the project cache on first use and reused thereafter.
codeanalyzer --input ./my-python-project --output ./out --codeql