sqlalchemyorg / zimports

Python import rewriter
MIT License
75 stars 6 forks source link

Allow splitting a single import over multiple lines #12

Closed timokau closed 2 years ago

timokau commented 4 years ago

If an import exceeds the character limit, black will split it to multiple lines:

from .tag_genome_object_ranking_dataset_reader import TagGenomeObjectRankingDatasetReader

becomes

from .tag_genome_object_ranking_dataset_reader import (
    TagGenomeObjectRankingDatasetReader,
)

but then zimports will change it back to the one-line format. This makes black and zimports incompatible. It would be nice if zimports could allow that kind of formatting.

zzzeek commented 4 years ago

please see #9 which is a stalled pull request that should implement this feature; it works for the user-contributed "multi-imports" mode but it should also work for a long single name as well (or if not, maybe it can be modified to do such). the PR otherwise needs only small changes and I would welcome contributors who want to pick it up.

zzzeek commented 2 years ago

going to see if zimports when it sees an import that doesnt need to be rewritten, that it keeps that line as it is. since we have this problem all over the place now.