'optimize imports' entirely unhelpful

I've been having a lot of trouble getting the Optimize Imports functionality to be helpful. My team follows the PEP8 import ordering, with imports sorted into three groups, and we also sort alphabetically within the groups.

Apparently, the "optimize imports" (http://www.jetbrains.com/pycharm/webhelp/optimizing-imports.html) command should do the grouping for me. However, it doesn't work right:

Correct import formatting
import datetime # Standard lib

import numpy # External

import my_module # local
import zz_module # local

Pycharm consistently finds some third-party import to put in the wrong place, for example, numpy, and also doesn't care when imports inside a group are in the wrong order:

"optimize imports" import formatting
import datetime # Standard lib
import numpy # External, in the wrong place

import zz_module # local
import my_module # local; optimize_imports does not fix mis-alphabetized imports

The incorrect grouping seems like a bug, and the lack of alphabetization seems like a missing feature. Together, they make the "optimize imports" feature entirely unhelpful for my team.
Am I missing something? If so, where can I report the bug/request the feature?
1 comment
Comment actions Permalink

I've been having some trouble too, but I found out the problem was that the environment setup was confusing Pycharm, making it treat my local library as a third-party library... I eventually managed to make it work. Alphabetical order works fine for me too. Try checking out your project dependencies and installed libraries, make a new virtualenv from scratch, I don't know...


Please sign in to leave a comment.