Search code examples
pythonpycharm

Can PyCharm's optimize imports also alphabetize them?


I am enjoying PyCharm's optimizing of Python imports - as well as removing unused imports, following PEP8 gives them a sensible layout and makes them easier to read. Is there any way to get PyCharm to additionally alphabetize them (which would make scanning them faster, for me at least)?


Solution

  • PyCharm does this automatically now by use of Code -> Optimize Imports. It also sorts them into groups per PEP 8.

    See https://www.jetbrains.com/help/pycharm/optimizing-imports.html for details.