Sooner or later, some of the imported classes
become redundant to the code.
Typically, you have to stop what you are doing, scroll to the head of the file, find the unused
imports, and remove them. It is rather easy to forget to remove imports when you remove usages.
PyCharm provides the
Optimize Imports feature, which enables you, whenever it
is convenient, to remove unused imports from your current file, or from all files in the current
directory at once.
Besides cleaning the code from the unused imports, PyCharm formats the existing import
statements according to the
Style Guide for Python Code. So doing,
PyCharm splits import statements into separate lines, and sorts them into groups (refer to the
Imports section for details).