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

Import in one line if the import fits within the line-length #2230

Closed
andrew000 opened this issue Feb 3, 2024 · 4 comments
Closed

Import in one line if the import fits within the line-length #2230

andrew000 opened this issue Feb 3, 2024 · 4 comments

Comments

@andrew000
Copy link

Is there a way to force isort to format such imports:

from redis.asyncio import (
    Redis,
)

Into the following:

from redis.asyncio import Redis
@bp72
Copy link
Contributor

bp72 commented Feb 4, 2024

Hi @andrew000!

Could you please share what configuration of isort you use, if any?

@andrew000
Copy link
Author

Hi @andrew000!

Could you please share what configuration of isort you use, if any?

[tool.isort]
py_version = 311
src_paths = ["src"]
line_length = 120
multi_line_output = 3
force_grid_wrap = 0
include_trailing_comma = true
split_on_trailing_comma = true
single_line_exclusions = ["."]
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]

@bp72
Copy link
Contributor

bp72 commented Feb 5, 2024

Thank you!
You can achieve the result in the topic if you set
split_on_trailing_comma = false
This setting prevents isort from formatting the line with the trailing comma to a single line import.
Here is a ticket with the initial discussion of this option: #1683

Let me know if there's anything else I can help with!

@andrew000
Copy link
Author

Thank you! You can achieve the result in the topic if you set split_on_trailing_comma = false This setting prevents isort from formatting the line with the trailing comma to a single line import. Here is a ticket with the initial discussion of this option: #1683

Let me know if there's anything else I can help with!

It helped. Thank you very much)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants