MCPcopy Index your code
hub / github.com/RustPython/RustPython / _method_removal_range

Function _method_removal_range

scripts/update_lib/cmd_auto_mark.py:389–407  ·  view source on GitHub ↗

Line range covering an entire method including decorators and a preceding COMMENT line.

(
    func_node: ast.FunctionDef | ast.AsyncFunctionDef, lines: list[str]
)

Source from the content-addressed store, hash-verified

387
388
389def _method_removal_range(
390 func_node: ast.FunctionDef | ast.AsyncFunctionDef, lines: list[str]
391) -> range:
392 """Line range covering an entire method including decorators and a preceding COMMENT line."""
393 first = (
394 func_node.decorator_list[0].lineno - 1
395 if func_node.decorator_list
396 else func_node.lineno - 1
397 )
398 if (
399 first > 0
400 and lines[first - 1].strip().startswith("#")
401 and COMMENT in lines[first - 1]
402 ):
403 first -= 1
404 # Also remove a preceding blank line to avoid double-blanks after removal
405 if first > 0 and not lines[first - 1].strip():
406 first -= 1
407 return range(first, func_node.end_lineno)
408
409
410def _build_inheritance_info(tree: ast.Module) -> tuple[dict, dict]:

Callers 2

remove_expected_failuresFunction · 0.85

Calls 2

startswithMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected