Coding style.

- Minor shortening of python_gut.
This commit is contained in:
Andrew Hamilton 2021-11-06 13:41:04 +10:00
parent b4b237ec1f
commit 90078f5d32

View file

@ -335,15 +335,11 @@ def python_coverage(path):
def _function_body_lines(python_source):
ranges = []
class FuncNodeVisitor(ast.NodeVisitor):
def _line_range(self, body):
return body[0].lineno - 1, body[-1].end_lineno
def visit_FunctionDef(self, node):
ranges.append(self._line_range(node.body))
def visit_AsyncFunctionDef(self, node):
ranges.append(self._line_range(node.body))
visit_AsyncFunctionDef = visit_FunctionDef
tree = ast.parse(python_source)
FuncNodeVisitor().visit(tree)
return ranges