/usr/lib/python3/dist-packages/pylama/lint/pylama_radon.py is in python3-pylama 7.3.3-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | from radon.visitors import ComplexityVisitor
from radon.complexity import add_inner_blocks
from pylama.lint import Linter as Abstract
class Linter(Abstract):
"""Radon runner."""
@staticmethod
def run(path, code=None, params=None, ignore=None, select=None, **meta):
"""Check code with Radon.
:return list: List of errors.
"""
complexity = params.get('complexity', 10)
no_assert = params.get('no_assert', False)
show_closures = params.get('show_closures', False)
visitor = ComplexityVisitor.from_code(code, no_assert=no_assert)
blocks = visitor.blocks
if show_closures:
blocks = add_inner_blocks(blocks)
return [
{'lnum': block.lineno, 'col': block.col_offset, 'type': 'R', 'number': 'R709',
'text': 'R701: %s is too complex %d' % (block.name, block.complexity)}
for block in visitor.blocks if block.complexity > complexity
]
|