Coding style.
- Minor shortening of python_gut.
This commit is contained in:
parent
b4b237ec1f
commit
90078f5d32
1 changed files with 1 additions and 5 deletions
|
|
@ -335,15 +335,11 @@ def python_coverage(path):
|
||||||
def _function_body_lines(python_source):
|
def _function_body_lines(python_source):
|
||||||
ranges = []
|
ranges = []
|
||||||
class FuncNodeVisitor(ast.NodeVisitor):
|
class FuncNodeVisitor(ast.NodeVisitor):
|
||||||
|
|
||||||
def _line_range(self, body):
|
def _line_range(self, body):
|
||||||
return body[0].lineno - 1, body[-1].end_lineno
|
return body[0].lineno - 1, body[-1].end_lineno
|
||||||
|
|
||||||
def visit_FunctionDef(self, node):
|
def visit_FunctionDef(self, node):
|
||||||
ranges.append(self._line_range(node.body))
|
ranges.append(self._line_range(node.body))
|
||||||
|
visit_AsyncFunctionDef = visit_FunctionDef
|
||||||
def visit_AsyncFunctionDef(self, node):
|
|
||||||
ranges.append(self._line_range(node.body))
|
|
||||||
tree = ast.parse(python_source)
|
tree = ast.parse(python_source)
|
||||||
FuncNodeVisitor().visit(tree)
|
FuncNodeVisitor().visit(tree)
|
||||||
return ranges
|
return ranges
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue