extract_method
Extract selected statements or an expression into a new method or function, with parameters and return values inferred from data flow.
Instructions
Extract a selected block of statements (or an expression) into a new method or function, with parameters and return values inferred from the data flow. Pass the file and the selection Range — start_line/start_character to end_line/end_character, 0-based, character in UTF-16 units, exactly as an editor selection. The selection must be complete statements or one complete expression. Options: replace_similar replaces other occurrences of the same pattern; to_global_scope extracts to module level; method_kind makes a classmethod or staticmethod. Defaults to a Dry Run preview; set apply=true to write. Read the code with your LSP first; leave formatting to black/ruff.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | ||
| name | Yes | ||
| root | No | ||
| apply | No | ||
| end_line | Yes | ||
| start_line | Yes | ||
| method_kind | No | ||
| end_character | Yes | ||
| replace_similar | No | ||
| start_character | Yes | ||
| to_global_scope | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||