-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Change isort.split-on-trailing-comma
default to false
#4153
Comments
I think the current default is "correct" because it's consistent with Black's behavior and isort's So, I'd rather err on the side of leaving this default as-is. Users are, of course, welcome to change the setting in their own projects :) |
Good point. Didn't consider |
I also found this behavior surprising. I think
|
I think you're misunderstanding isort's behavior :) |
unsplit existing 1-line imports astral-sh/ruff#4153
Is this not a bug in isort? The documentation says that |
If that's the case, it sounds like a bug indeed. Where does it say that? https://pycqa.github.io/isort/docs/configuration/options.html#split-on-trailing-comma only says the behavior mimics black when enabled, not that it's set to true with black profile. |
In the Profiles documentation: |
(I agree with you that I'm not seeing this behavior in practice, so not certain what's wrong: the documentation or the implementation.) |
Ah OK, I was looking at the "Black Compatibility" and "Options" sections of their docs. |
One minor note I wanted to bring up, it is inconsistent with how Black would have formatted it, but if isort or Ruff do format it to: from a import b Black is happy with it, just like if a user would have compressed it to one line manually. We've been running this way with isort + black for years, but it does seem like this might not have been intentional as mentioned in this thread. I do find this useful so I'm glad to hear there is an opt-out, since unlike other parts of code, it'd be much less likely for a user to intentionally want to lengthen imports as they might some other code since imports are mostly boilerplate. In my experience it's much more likely that a user has their editor automatically remove an unused import but it leaves the trailing comma for another import from that same module. I've observed that over time in large code bases without |
Great point. I'd appreciate departing from
|
unsplit existing 1-line imports astral-sh/ruff#4153
isort did this by default, though it’s unclear whether that was intended; see astral-sh/ruff#4153. Signed-off-by: Anders Kaseorg <[email protected]>
isort did this by default, though it’s unclear whether that was intended; see astral-sh/ruff#4153. Signed-off-by: Anders Kaseorg <[email protected]>
isort did this by default, though it’s unclear whether that was intended; see astral-sh/ruff#4153. Signed-off-by: Anders Kaseorg <[email protected]>
isort did this by default, though it’s unclear whether that was intended; see astral-sh/ruff#4153. Signed-off-by: Anders Kaseorg <[email protected]> (cherry picked from commit 733083c)
Currently defaults to true, causing this to stay as is
I think a better default would be to fold:
The text was updated successfully, but these errors were encountered: