PyCharm Edu 2019.2 Help

Optimizing Imports

Optimize imports in the project

  1. Place the caret at the Project tool window and do one of the following:

    • On the main menu, choose Code | Optimize Imports.

    • Press Ctrl+Alt+O.

    The Optimize Imports dialog box opens.

  2. If your project is under version control, the option Only VCS changed files is enabled. Select or clear this option as required.

  3. Click Run.

One way of dealing with unused import is to use the quick-fix that appears when you set the caret at the highlighted unused import. However, you can optimize imports in a larger scope as described below.

Optimize imports in the current file

  1. On the main menu, choose Code | Optimize Imports.

  2. Press Ctrl+Alt+O.

  3. Place the caret at the import statements, click icons actions intentionBulb, and choose Remove unused import.

  4. Open the Reformat File Dialog Ctrl+Shift+Alt+L and select the Optimize imports checkbox.

Last modified: 22 January 2020