radon
Code Metrics in Python
What it is and what it does
Radon is a static analysis tool that measures code quality through multiple metrics. It computes cyclomatic complexity (how many independent paths flow through code), raw metrics like lines of code and comment density, Halstead metrics (effort and difficulty estimates), and a maintainability index similar to Visual Studio's implementation. You run it from the command line or call it programmatically to analyze Python files and get a report on code structure and complexity.
The tool is designed to integrate into CI/CD pipelines and code review platforms (Codacy, Code Climate, coala, CodeFactor all support it). It depends only on mando for CLI handling and colorama for optional colored output. It can also analyze Jupyter notebooks if the optional nbformat package is installed.
Use it for:
- Identify overly complex functions that need refactoring by running cyclomatic complexity analysis on a codebase
- Measure code maintainability trends over time by tracking raw metrics and maintainability index across releases
- Integrate code quality gates into CI/CD by using radon to fail builds when complexity thresholds are exceeded
- Analyze Jupyter notebooks for code quality metrics alongside regular Python files
- Generate code quality reports for code review or documentation purposes
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Radon computes code metrics from Python source files, including cyclomatic complexity, raw metrics (lines of code, comments, blanks), Halstead metrics, and maintainability index.
Yes, with conditions. Radon is stable and widely used (5.7M monthly downloads, top 5000 packages), with no known vulnerabilities and low install friction. However, the project is dormant—no releases in over a year and no commits since October 2024. Install it if you need code metrics for analysis or CI integration, but do not expect active maintenance or support for very recent Python versions. For active monitoring and CI enforcement, consider xenon as an alternative.
Install
radon on PyPI
pip
pip install radonuv
uv add radonpoetry
poetry add radonInstalling radon
Before you install
Low install friction with only two runtime dependencies (mando and colorama). Dormant maintenance status—last release was over a year ago and no commits since October 2024—but the package is marked Production/Stable and has accumulated 2005 repository stars.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions.
Quickstart
pip install radon
radon cc mymodule.py -a
# Or programmatically:
from radon.complexity import cc_visit
with open('mymodule.py') as f:
results = cc_visit(f.read())
On Windows or systems with non-UTF-8 default encoding, set the RADONFILESENCODING environment variable to UTF-8 to analyze files with Unicode characters.
Verify before relying
- Whether the package remains actively maintained or is effectively unmaintained despite Production/Stable status
- Compatibility with Python versions beyond 3.8 (classifiers list up to 3.9 but description mentions 3.8 as the upper bound)
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — mando, colorama |
| Maintenance | dormant — 1,237 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,780,891/month — #2,038 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: radon-6.0.1-py2.py3-none-any.whl
Keywords: static, analysis, code, complexity, metrics
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
xenonXenon monitors Python code complexity by…
permissive · top 5,000 on PyPI
lizardLizard analyzes code complexity and detects…
permissive · top 5,000 on PyPI
mccabeMeasures cyclomatic complexity of Python…
permissive · top 1,000 on PyPI
cognitive-complexityCalculates cognitive complexity scores for…
permissive · top 15,000 on PyPI
complexipyCalculates cognitive complexity scores for…
permissive · top 15,000 on PyPI
pygountPygount counts source lines of code (SLOC)…
permissive · top 15,000 on PyPI
django-prometheusExports Django application metrics (requests,…
permissive · top 5,000 on PyPI
flake8-cognitive-complexityA flake8 extension that checks Python code for…
permissive · top 15,000 on PyPI
gdtoolkitGDScript parser, linter, formatter, and code…
permissive · top 15,000 on PyPI
aws-cdk.aws-cloudwatchDefines CloudWatch metrics, alarms, and…
permissive · top 15,000 on PyPI