I have a import statement:
from review.domains.services import (
CompanyAPI as CompanyAPIService,
CompanyClientException,
Review as ReviewService,
Job as JobService,
JobGetException,
Qualifications,
)
isort is changing this to:
from review.domains.services import CompanyAPI as CompanyAPIService
from review.domains.services import CompanyClientException
from review.domains.services import Job as JobService
from review.domains.services import JobGetException, Qualifications
from review.domains.services import Review as ReviewService
my isort config is the following:
'include_trailing_comma': 1,
'multi_line_output': 3,
'line_length': 99
I would like to keep it as one import statement rather then several. It seems like the reason is the use of aliases as. It's working as expected if I remove the alias definitions.
Hi @matthias-mess,
I can understand the confusion here! By default, isort puts as imports on their own line, as they are seen as exceptional, and not intended for broad use, but more for as-needed aliasing - in particular to help with refactoring. In the case where they are widely used, and you want to have them mixed isort has the --combine-as CLI flag or combine_as_imports config setting to provide the behaviour that you seek.
Thanks!
~Timothy
Most helpful comment
Hi @matthias-mess,
I can understand the confusion here! By default, isort puts as imports on their own line, as they are seen as exceptional, and not intended for broad use, but more for as-needed aliasing - in particular to help with refactoring. In the case where they are widely used, and you want to have them mixed isort has the
--combine-asCLI flag orcombine_as_importsconfig setting to provide the behaviour that you seek.Thanks!
~Timothy