Consider not wrapping a single import when the line is too long · Issue #3324 · psf/black (original) (raw)

Describe the style change

When an import line is too long, and it only has a single imported symbol, it's more readable to NOT wrap the line.

Examples in the current Black style

from company.organization.products.my_awesome_learning_system.backend.handlers import ( register, ) from company.organization.products.my_awesome_learning_system.common import logging from company.organization.products.my_awesome_learning_system.utils import ( authentication, )

Desired style

from company.organization.products.my_awesome_learning_system.backend.handlers import register from company.organization.products.my_awesome_learning_system.common import logging from company.organization.products.my_awesome_learning_system.utils import authentication

Additional context

The current behavior works very well in the majority cases. If the import line has more than one imports, it should continue wrapping them:

from company.organization.products.my_awesome_learning_system.backend.handlers import ( enroll, login, register, )

But for code bases that follow the Google Python Style Guide to only import modules/packages, never individual functions/classes from a module (it won't import multiple symbols in the same line, except from typing), Black can make the imports very awkward.