replace_signature
Replace a function signature or class header while keeping the body and existing decorators or annotations intact, so you can update parameters, return types, or names without rewriting the implementation.
Instructions
Replace the signature of a function, or the header of a class, keeping
its body. Existing decorators, Java annotations and a C++ template <...> header stay unless new_signature has its own. Code that
read_symbol's signature starts with (a JS/TS const f =, a closure's
key, a TS declare, a Ruby private) is replaced when new_signature
starts with it, else kept. A method without a body keeps its ;.
Refused for a symbol with no signature, such as a variable.
Use this when: changing a function's parameters, return type or name. Don't use this when: the body changes too (replace_function), or one parameter is added or removed (add_parameter, remove_parameter).
Example: target="LRUCache.get" new_signature="def get(self, key, default=None):"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | Function or method name as list_symbols lists it, dotted for nesting ('LRUCache.get'); overloads take parameter types ('A.m(int)'). | |
| file_path | Yes | Absolute path to the source or config file. | |
| new_signature | Yes | Everything from the start of the definition up to its body, as read_symbol(depth='signature') returns it (e.g. 'def get(self, key):', JS 'get(key, d)' without the '{'); indentation on its first line is ignored. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |