Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forced_together option or alternative for keeping top-level modules together #1021

Closed
DylanYoung opened this issue Sep 27, 2019 · 4 comments
Closed
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers

Comments

@DylanYoung
Copy link

DylanYoung commented Sep 27, 2019

I'd like to see an equivalent of the forced_separate option called forced_together that takes section names and removes spaces between them.

Here is the scenario:

I have two modules that I want to view as "the same" (they are separate for historic reasons only). The problem is that isort lifts the imports above the from imports, messing up the order:

import foo
from blah import ... 
from foo import ...

Which is ugly as sin.

An alternative would be an option to only lift the bare imports for top-level modules (`--group-toplevel'), which would change the output to:

from foo import ...
import foo
from blah import ... 
@DylanYoung
Copy link
Author

UPDATE: Just found the no_lines_before option! This should work.

@DylanYoung
Copy link
Author

FYI: it's missing from the wiki

@DylanYoung
Copy link
Author

DylanYoung commented Sep 27, 2019

I still think a more generalized option, subgroup by top level module, or something to that effect would be valuable. That way imports from the same module within a section would stay together, but the "bare" imports would still float to the top of each of those subgroups (or bottom if the reverse flag is specified).

@timothycrosley timothycrosley added documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers labels Feb 9, 2020
@timothycrosley
Copy link
Member

Relooking at this now, I think this is now covered by this documentation: https://github.com/timothycrosley/isort#controlling-how-isort-sections-from-imports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants