spyder
spyder copied to clipboard
Add option/plugin to sort import statements, perhaps via isort
I think a nice refactoring feature would be organization of import statements.
I found this nifty package called isort which I think would be a good addition to Spyder. It appears to be actively maintained and supports Python 2.6 to 3.4. It's also under the MIT licence.
The example shown on Timothy's page explains things quite nicely:
Before isort:
from my_lib import Object
print("Hey")
import os
from my_lib import Object3
from my_lib import Object2
import sys
from third_party import lib15, lib1, lib2, lib3, lib4, lib5, lib6, lib7, lib8, lib9, lib10, lib11, lib12, lib13, lib14
import sys
from __future__ import absolute_import
from third_party import lib3
print("yo")
After isort:
from __future__ import absolute_import
import os
import sys
from third_party import (lib1, lib2, lib3, lib4, lib5, lib6, lib7, lib8,
lib9, lib10, lib11, lib12, lib13, lib14, lib15)
from my_lib import Object, Object2, Object3
print("Hey")
print("yo")
I have a bit of plugin experience already, so I'll try making a plugin to do this. My main issue is that I'll get a plugin to a working proof-of-concept stage and then not bother making it look nice, so someone might want to take over afterwards.