PyCharm - Reformat Selected Text but Optimize Imports and MERGE Duplicate Import Sources to Single Import Line

Answered

I love most things in PyCharm. I also love how this forum is not dead - knowledgeable people from JetBrains actually reply. Thanks to you all.

My question

When I CTRL + ALT + SHIFT + L to Reformat selected text, I have "Optimize imports" selected, then hit run.

The Result is this:

from content.utils import slugifier
from .fields import S3DirectField
from .fields import SorlImageField
from .validators import SlugValidator

I would prefer the result to be this:

from content.utils import slugifier
from .fields import S3DirectField, SorlImageField
from .validators import SlugValidator
0
2 comments

Hi,

You need to enable the following in settings:

1

Nice! Of course. Exactly what I needed. Thank you.

0

Please sign in to leave a comment.