xenon
Monitor code metrics for Python on your CI server
What it is and what it does
Xenon is a command-line tool that wraps Radon to measure cyclomatic complexity across a Python codebase and enforce complexity thresholds. It calculates three metrics: average complexity across all blocks, per-module complexity, and absolute complexity of individual blocks, each ranked from A (simplest) to F (most complex). You set thresholds for each metric, and xenon exits with a non-zero code if any threshold is violated, making it suitable for blocking commits or failing CI builds when code becomes too complex.
Typically used in two contexts: as a pre-commit hook to prevent overly complex code from entering version control, or as a CI step to monitor complexity trends over time. It accepts glob patterns to exclude or ignore files and directories, and integrates with pre-commit frameworks. The package depends on radon for the actual complexity analysis, requests for potential HTTP operations, and PyYAML for configuration parsing.
Use it for:
- Enforce complexity limits in a CI/CD pipeline to prevent code from becoming unmaintainable as features are added.
- Block commits via a pre-commit hook when a developer introduces a function or module exceeding your team's complexity threshold.
- Monitor average codebase complexity over time to catch gradual increases in technical debt.
- Set per-module complexity caps to ensure no single module becomes a maintenance bottleneck.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Xenon monitors Python code complexity by measuring cyclomatic complexity across your codebase and fails your build when thresholds are exceeded, typically used in CI/CD pipelines and git commit hooks.
Yes, if you need lightweight complexity enforcement in CI or pre-commit workflows and can accept dormant maintenance. The package is stable and does one job well, but expect no active support or updates; if you require ongoing maintenance or advanced complexity analysis features, consider alternatives. No known vulnerabilities and low install friction make it a low-risk addition to existing pipelines.
Install
xenon on PyPI
pip
pip install xenonuv
uv add xenonpoetry
poetry add xenonInstalling xenon
Before you install
Low friction install with three straightforward runtime dependencies (radon, requests, PyYAML). Maintenance is dormant—last release was 662 days ago—so expect no active bug fixes or feature updates, though the package remains functional for its narrow purpose.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions; you may use, modify, and distribute xenon freely as long as you include the license notice.
Quickstart
pip install xenon
xenon --max-absolute B --max-modules A --max-average A /path/to/code
Requires Python 2.7 or 3.6+ (classifiers indicate support through 3.12); xenon measures cyclomatic complexity via radon, so results depend on radon's analysis capabilities.
Verify before relying
- Whether dormant maintenance (662 days since last release) affects compatibility with recent Python patch releases or modern CI platforms.
- Whether the package's complexity thresholds (A–F ranks) align with your team's code quality standards without requiring custom configuration.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — radon, requests, PyYAML |
| Maintenance | dormant — 662 days since the last release |
| First released | |
| Downloads | 1,359,618/month — #4,004 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: xenon-0.9.3-py2.py3-none-any.whl
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
coverage-thresholdValidates Python code coverage against…
permissive · top 15,000 on PyPI
lizardLizard analyzes code complexity and detects…
permissive · top 5,000 on PyPI
radonRadon computes code metrics from Python source…
permissive · top 5,000 on PyPI
mccabeMeasures cyclomatic complexity of Python…
permissive · top 1,000 on PyPI
flake8-cognitive-complexityA flake8 extension that checks Python code for…
permissive · top 15,000 on PyPI
complexipyCalculates cognitive complexity scores for…
permissive · top 15,000 on PyPI
flake8-expression-complexityA flake8 extension that detects overly complex…
permissive · top 15,000 on PyPI
pysentry-rsPySentry scans Python projects for known…
permissive · top 15,000 on PyPI
flake8-annotations-complexityA flake8 plugin that flags type annotations…
permissive · top 15,000 on PyPI
mozsystemmonitorMonitors system resource usage by wrapping…
copyleft · top 15,000 on PyPI