Check if the method body is just 'return super().method_name()' or 'return await super().method_name()'.
(func_node: ast.FunctionDef | ast.AsyncFunctionDef)
| 361 | |
| 362 | |
| 363 | def _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 | |
| 389 | def _method_removal_range( |