Scalpel
raw JSON → 1.0b0 verified Fri May 01 auth: no python
Scalpel is a Python program analysis framework for building static analysis tools (e.g., call graph extraction, type inference, SSA construction). The current version is 1.0b0 (pre-release beta). Release cadence is irregular; last updated 2022.
pip install python-scalpel Common errors
error ModuleNotFoundError: No module named 'scalpel' ↓
cause Package is installed as 'python-scalpel' but import name is 'scalpel'.
fix
pip install python-scalpel; then import scalpel.
error AttributeError: module 'scalpel' has no attribute 'Scalpel' ↓
cause Old import path used (e.g., `from scalpel.core import Scalpel`) or scalpel not installed.
fix
Use
from scalpel import Scalpel. error TypeError: 'module' object is not callable ↓
cause Importing `scalpel` but trying to instantiate it as a class.
fix
Use
from scalpel import Scalpel then Scalpel(...). Warnings
gotcha Scalpel is still in beta (1.0b0); API is unstable and may change without notice. ↓
fix Pin to exact version and test thoroughly.
deprecated The old import path `scalpel.core.Scalpel` has been removed; use `scalpel.Scalpel` directly. ↓
fix Use `from scalpel import Scalpel`.
breaking Python 3.10+ support is experimental; some AST nodes may not be handled correctly. ↓
fix Prefer Python 3.8 or 3.9 for production use.
Imports
- Scalpel wrong
from python_scalpel import Scalpelcorrectfrom scalpel import Scalpel - CallGraph
from scalpel.call_graph import CallGraph - CFG
from scalpel.cfg import CFG
Quickstart
from scalpel import Scalpel
from scalpel.call_graph import CallGraph
scalpel = Scalpel('path/to/script.py')
call_graph = scalpel.analyze_call_graph()
print(call_graph.nodes, call_graph.edges)