Code Metrics in Python
Radon is a Python tool that computes various metrics from the source code. Radon can compute:
Radon will run from Python 2.7 to Python 3.6 with a single code base and without the need of tools like 2to3 or six. It can also run on PyPy without any problems (currently PyPy 5.7.1 is used in tests).
Radon depends on as few packages as possible. Currently only
strictly required (for the CLI interface).
colorama is also listed as a
dependency but if Radon cannot import it, the output simply will not be
Note: Python 2.6 was supported until version 1.5.0. Starting from version 2.0, it is not supported anymore.
$ pip install radon
Or download the source and run the setup file:
$ python setup.py install
Radon can be used either from the command line or programmatically. Documentation is at https://radon.readthedocs.org/.
$ radon cc sympy/solvers/solvers.py -a -nc sympy/solvers/solvers.py F 346:0 solve - F F 1093:0 _solve - F F 1434:0 _solve_system - F F 2647:0 unrad - F F 110:0 checksol - F F 2238:0 _tsolve - F F 2482:0 _invert - F F 1862:0 solve_linear_system - E F 1781:0 minsolve_linear_system - D F 1636:0 solve_linear - D F 2382:0 nsolve - C 11 blocks (classes, functions, methods) analyzed. Average complexity: F (61.0)
Actually it’s even better: it’s got colors!
Note about file encoding
On some systems, such as Windows, the default encoding is not UTF-8. If you are
using Unicode characters in your Python file and want to analyze it with Radon,
you’ll have to set the
RADONFILESENCODING environment variable to
If you are looking to use
radon on a CI server you may be better off with
xenon. Although still experimental, it will
fail (that means exiting with a non-zero exit code) when various thresholds are
radon is more of a reporting tool, while
xenon is a monitoring
If you are looking for more complete solutions, read the following sections.
Radon is also supported in coala. To add Radon’s checks to coala, simply add the RadonBear to one of the sections in your .coafile.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|radon-2.0.2-py2.py3-none-any.whl (44.0 kB) Copy SHA256 Checksum SHA256||3.6||Wheel||Jun 4, 2017|
|radon-2.0.2.tar.gz (3.5 MB) Copy SHA256 Checksum SHA256||–||Source||Jun 4, 2017|