One Import Per Line Preference

Tell PyCharm to put each import on a separate line when it cleans up your imports.

Writing Python code means importing stuff. Lots of code can mean lots of imports. Python is pretty picky about style, and so are you, which can mean lots of tedious manual gardening of your imports.

PyCharm's Optimize Imports acts as your import janitor and it has settings which let you specify some options on style import. PyCharm 2018.3 adds a preference: "One Import Per Line". With this setting in place, PyCharms Optimize Imports action will rewrite lines like this:

from project.models import Item, User, Account

...into lines like this:

from project.models import Account
from project.models import Item
from project.models import User

Don't forget, PyCharm can also run the Optimize Imports action, with options such as Only VCS changed files, across all the files in your project. Also, check out the other ways to customize import styles.

Interested in optimizing your imports?

call to action image

Keeping your imports clean and tidy is a great code readability tip. Check it out!

Learn More


Related Resources

Navigation Bar - All the power!
Navigation Bar - All the power!
The Navigation Bar can do much more than you think!
Clean Up Messy Imports With Optimize Imports
Clean Up Messy Imports With Optimize Imports
Quickly remove any unused imports and more.
Find in Path with the Navigation Bar
Find in Path with the Navigation Bar
Use the Navigation bar and Find in File together and be faster than all of your team members.