The Change Signature refactoring combines several different modifications that can be applied to a function signature. You can use this refactoring to:
change the function name
add, remove, and reorder parameters
assign default values to the parameters
When changing a function signature, PyCharm searches for all usages of the function and updates all the calls, implementations, and override replacements of the function that can be safely modified to reflect the change.
Change signature in place
You can also change the signature of a function as you type in the editor.
Start adding or editing the parameter of a function. PyCharm will display in the gutter.
Click the icon in the gutter or press Alt+Enter.
If you are adding a new parameter, PyCharm will offer you to add a default value for it as well as update the usages.
If you are editing a parameter, PyCharm will offer to update the usages for you.
Click Update to apply the suggestions.
Changing a function signature
Position the caret at the name of the function that you want to refactor.
Press Ctrl+F6. Alternatively, selectfrom the main or context menu.
In the Change Signature dialog, make necessary changes to the function signature depending on your needs:
Change the function name. To change the name, edit the text in the Name field.
Manage the function parameters. To configure the parameters, use the table and buttons in the Parameters area:
To add a new parameter, click and specify the new parameter's properties in the corresponding table row.
To remove a parameter, select any row and click .
To reorder the parameters, click and . For example, if you want to put a certain parameter first in the list, click any of the cells in the row corresponding to that parameter, and then click the required number of times.
You can specify the default value of the newly added parameter. Do not select the Use default value in signature checkbox to use the specified value in existing calls as an explicit placeholder.
To see the expected changes and make adjustments prior to the refactoring, click Preview.