CLI usage
The codeanalyzer command runs static analysis on a Python project and emits a PyApplication artifact. This guide walks through the common invocations; for the full flag table see the CLI reference.
Basic analysis
Section titled “Basic analysis”The only required flag is --input (-i), the project root:
codeanalyzer --input ./my-python-projectWith no --output, the analysis is printed to stdout as compact JSON. Add --output (-o) to write it to a file instead:
codeanalyzer --input ./my-python-project --output ./out# -> ./out/analysis.jsonOutput formats
Section titled “Output formats”The default format is JSON. Pass --format msgpack (-f) for a gzip-compressed MessagePack artifact — smaller and faster to load for large projects:
codeanalyzer --input ./my-python-project --output ./out --format msgpack# -> ./out/analysis.msgpackThe CLI logs the compression ratio relative to JSON when it writes msgpack. The schema is identical across formats; only the serialization differs.
Enabling CodeQL
Section titled “Enabling CodeQL”By default the call graph comes from Jedi’s lexical analysis. Add --codeql to resolve additional edges — including RPC, third-party, and dynamically-dispatched targets — and merge them with the Jedi edges. CodeQL also backfills resolved callees on Jedi call sites it couldn’t resolve.
codeanalyzer --input ./my-python-project --codeqlCaching: eager vs lazy
Section titled “Caching: eager vs lazy”Analysis is lazy by default: codeanalyzer caches results under .codeanalyzer/ and reuses the entries for files that haven’t changed (detected by mtime, size, and content hash). Pass --eager to rebuild everything from scratch:
# Lazy (default) — reuse unchanged files from cachecodeanalyzer --input ./my-python-project
# Eager — rebuild the analysis and the virtual environmentcodeanalyzer --input ./my-python-project --eagerControl where the cache lives with --cache-dir (-c). If unset, it defaults to .codeanalyzer in the input project directory:
codeanalyzer --input ./my-python-project --cache-dir /tmp/ca-cache# -> /tmp/ca-cache/.codeanalyzerBy default the cache is kept after a run. Pass --clear-cache to delete it on exit (useful in CI):
codeanalyzer --input ./my-python-project --clear-cacheSingle-file mode
Section titled “Single-file mode”To analyze one file rather than the whole project, pass --file-name relative to --input:
codeanalyzer --input ./my-python-project --file-name src/app/routes.pyThe path must exist under --input and end in .py.
Including test files
Section titled “Including test files”Test files are skipped by default — any file under a test/tests directory, or named test_*.py / *_test.py. Include them with --include-tests:
codeanalyzer --input ./my-python-project --include-testsParallelism with Ray
Section titled “Parallelism with Ray”For large projects, --ray distributes symbol-table construction across workers:
codeanalyzer --input ./large-project --rayVerbosity
Section titled “Verbosity”The tool is quiet by default. Stack -v for progressively more logging:
codeanalyzer --input ./my-python-project -v # infocodeanalyzer --input ./my-python-project -vv # debugcodeanalyzer --input ./my-python-project -vvv # tracePutting it together
Section titled “Putting it together”A typical CI invocation — eager rebuild, CodeQL on, msgpack out, cache discarded:
codeanalyzer \ --input ./my-python-project \ --output ./artifacts \ --format msgpack \ --codeql \ --eager \ --clear-cache \ -v