PyCharm 2024.3 Help

Override methods of a superclass

You can override any method of a parent class by generating necessary code from a predefined template. PyCharm creates a stub that contains a call to the method of the superclass, leaving the developer with the task of providing some meaningful source code in the method's body.

Override a method of a superclass

  1. On the Code menu, click Override methods Ctrl+O. Alternatively, you can right-click anywhere in the class file, then click Generate Alt+Insert, and select Override methods.

  2. Select the methods to override (hold the Shift or Ctrl key to perform a multi-selection). The list does not include the methods that are already overridden or cannot be accessed from the current subclass.

    Select methods to override
  3. Click OK and provide the source code for the method body.

    Hover over the Override icon in the gutter to view the name of the base class. Click it to open the overridden method declaration.

    Overriding method icon in the gutter
Last modified: 08 October 2024