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

merging import lines like isort #6471

Closed
nijel opened this issue Aug 10, 2023 · 2 comments
Closed

merging import lines like isort #6471

nijel opened this issue Aug 10, 2023 · 2 comments
Labels
needs-info More information is needed from the issue author

Comments

@nijel
Copy link
Contributor

nijel commented Aug 10, 2023

After some refactoring, several imports were removed and this was left:

from foo import (
    bar,
    baz,
)

bar()
baz()

With isort this is nicely formatted as:

from foo import bar, baz

bar()
baz()

But ruff does no formatting here and keeps the file as is.

Ruff 0.0.284 was executed as ruff check --fix --select I test.py with no config, isort as isort test.py with not config.

@charliermarsh
Copy link
Member

I think you’re looking for this setting: https://beta.ruff.rs/docs/settings/#isort-split-on-trailing-comma. Ruff defaults it to true while isort does not. (It’s a point of confusion as the isort docs state it defaults to true for their Black configuration, but doesn’t seem to do so in practice.)

@charliermarsh charliermarsh added the needs-info More information is needed from the issue author label Aug 10, 2023
@nijel
Copy link
Contributor Author

nijel commented Aug 10, 2023

Thanks, that's it. While reading through the doc, I didn't realize that something called split will actually toggle folding.

And isort documentation is indeed wrong on this, I've created PyCQA/isort#2163 for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-info More information is needed from the issue author
Projects
None yet
Development

No branches or pull requests

2 participants