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

Function _is_super_call_only

scripts/update_lib/cmd_auto_mark.py:363–386  ·  view source on GitHub ↗

Check if the method body is just 'return super().method_name()' or 'return await super().method_name()'.

(func_node: ast.FunctionDef | ast.AsyncFunctionDef)

Source from the content-addressed store, hash-verified

361
362
363def _is_super_call_only(func_node: ast.FunctionDef | ast.AsyncFunctionDef) -> bool:
364 """Check if the method body is just 'return super().method_name()' or 'return await super().method_name()'."""
365 if len(func_node.body) != 1:
366 return False
367 stmt = func_node.body[0]
368 if not isinstance(stmt, ast.Return) or stmt.value is None:
369 return False
370 call = stmt.value
371 # Unwrap await for async methods
372 if isinstance(call, ast.Await):
373 call = call.value
374 if not isinstance(call, ast.Call):
375 return False
376 if not isinstance(call.func, ast.Attribute):
377 return False
378 # Verify the method name matches
379 if call.func.attr != func_node.name:
380 return False
381 super_call = call.func.value
382 if not isinstance(super_call, ast.Call):
383 return False
384 if not isinstance(super_call.func, ast.Name) or super_call.func.id != "super":
385 return False
386 return True
387
388
389def _method_removal_range(

Callers 4

test_syncMethod · 0.90
test_asyncMethod · 0.90
remove_expected_failuresFunction · 0.85

Calls 2

lenFunction · 0.85
isinstanceFunction · 0.85

Tested by 2

test_syncMethod · 0.72
test_asyncMethod · 0.72