PyCharm 2020.1 Help

Change signature

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.

Changing a function signature

  1. Position the caret at the name of the function that you want to refactor.

  2. Press Ctrl+F6. Alternatively, select Refactor | Change Signature from the main menu or from the context menu.

  3. In the Change Signature dialog, make necessary changes to the function signature depending on your needs:

    Change signature animation

    • 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 the buttons in the Parameters area:

      • To add a new parameter, click The Add button and specify the new parameter's properties in the corresponding table row.

      • To remove a parameter, select any row and click The Remove button.

      • To reorder the parameters, click The Up icon and The down icon. 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 Up icon 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.

  4. Click Refactor.

  5. To see the expected changes and make adjustments prior to the refactoring, click Preview.

Last modified: 20 July 2020