Analyze dependencies in a Python project.
At the moment, depgraph performs three main tasks:
- Analyze the (nested) scopes in a Python file.
- Analyze certain variable assignments in a Python file.
- Crawl the dependency graph of a Python file.
Basic usage:
python -m depgraph <file_path>
Example:
python -m depgraph ./src/depgraph/processors/process_file.py
file_path
: Path to the Python file to analyze--depth
: Depth of the analysis (default: 4)--log-level
: Set logging level (DEBUG, INFO) (default: INFO)--scope-filter
: Filter output to a specific scope (e.g., '.outer.Inner.method')--output-file
: Write results to specified file--output-format
: Format for output file (JSON) (default: JSON)
Example with all options:
python -m depgraph ./src/depgraph/processors/process_file.py \
--depth 6 \
--log-level DEBUG \
--scope-filter "<module>.my_function"
When using --output-file
, the analysis results will be written to the specified file in JSON format, which includes:
- Scope analysis
- Assignment information
- Dependency graph information
- Import relationships
Example with output file:
python -m depgraph ./src/depgraph/processors/process_file.py \
--log-level DEBUG \
--output-file ./depgraph.json