Menu

#141 request: make Organize Imports follow PEP 8

open
nobody
None
5
2006-06-24
2006-06-24
No

It would be nice if Organize Imports split them into
groups like the PEP 8 ones:

system

3rd party site-packages

found on PYTHONPATH

src package

src current package

with bonus points for converting absolute imports to
relative imports.

Double bonus points for splitting import a,b into two
lines.

-- Chad

Discussion

  • davmp

    davmp - 2006-08-23

    Logged In: YES
    user_id=1582584

    Just saw a presentation by Guido regarding the future of
    Python. Relative imports are problematic and are going away
    so you should really be converting relative imports to
    absolute imports, not vice-versa.

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2006-08-24

    Logged In: YES
    user_id=617340

    I agree... there should be an option to convert relative
    imports to absolute imports automatically.

     
  • Steve Lianoglou

    Steve Lianoglou - 2007-03-27

    Logged In: YES
    user_id=995731
    Originator: NO

    I was going to add a feature request for something similar (following suggestion from bug http://sourceforge.net/tracker/index.php?func=detail&aid=1683348&group_id=85796&atid=577329, but this is basically what I'm talking about (except for changing absolute imports to relative ones and vice versa (though I can see how some might find it useful)).

    If it's hard to follow the PEP to the letter, maybe you can do it in this order:

    (1) use the libraries found in "the builtins" section of the Python Interpreter preference pane as a proxy for "the system" imports

    (2) Everything else is a 3rd party lib
    (3) Follow up with all the src files that are imported from w/in the files specified in *the project's* PYTHON path (typically the python src folder).

    And bonus points if you can separate each category above with a blank line for good measure ;-)

     
  • Jeremy Carroll

    Jeremy Carroll - 2013-02-27

    I have this working, also removal of unused imports - I expect to submit a patch this week or next

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.