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

force_single_line for the black profile #1791

Closed
WhyNotHugo opened this issue Jul 25, 2021 · 2 comments
Closed

force_single_line for the black profile #1791

WhyNotHugo opened this issue Jul 25, 2021 · 2 comments
Labels
invalid This doesn't seem right

Comments

@WhyNotHugo
Copy link

WhyNotHugo commented Jul 25, 2021

I'd like to bring up for discussion the idea of changing the black profile to use force_single_line=true, which reduces merge conflicts by a lot.

This aligns well with black's goal to reduce merge conflicts.

I've mentioned it on the black side, but was told that it's best to open a discussion here.

Is this change something that can happen?

cc: @ichard26

@Jackenmen
Copy link

I use black profile so that I get maximum interoperability with black's formatter, not so much to adhere to its code style philosophy (and arguably, usage of parenthesis and magic trailing comma handling in multiline from imports is more in line with Black's philosophy anyway; see also #1683). I feel this is something that is best left to the user, same as other settings like combine_as_imports. Personally, I also find it quite disruptive to make this change to the profile now, considering that most users probably were not using this option already. The documentation advertises the profiles as "The following profiles are built into isort to allow easy interoperability with common projects and code styles." which makes me think this would be something that most of the users were not expecting to happen when they chose to use the profile rather than manually configure each option.

@timothycrosley timothycrosley added the invalid This doesn't seem right label Jul 25, 2021
@timothycrosley
Copy link
Member

I hate to dash your dreams so quickly, but this won't happen at the isort level. The good news is you can always configure it yourself or even very easily create your own public shared profile that you can proliferate through out your own projects.


Now to the reasons why:

  1. isort can't do such a sweeping change because of its formatting guarantee (unless, pragmatically, black itself forced it's hand by introducing an incompatibility.) isort 4.x.x lived as a major release just shy of 5 years. isort 5.x.x turned one just a few weeks ago, and I imagine it will stay around for a similar time frame. This project values stability to a large degree. So even if I agreed with the change, you would need to wait a long time before it was realized.
  2. I fundamentally disagree with the premise of this ticket. I can see why you would like this, and isort supports it as an option, but to me the suggested change is very much in disagreement with how black formats, and Python's own goal of readability.

As long as Black does this:

list = ["a", "b", "c"]
really_long_list = [
   "a",
   "b",
   "c"...
]

isort should do this:

from x import a, b, c
from really_long_import (
    a,
    b,
    c,
)

In my mind, repeating the import package over and over needlessly, is unreadable and messy.
This:

from typing import Any, Callable, Dict, List, Tuple

is just soooo much easier to digest and cleaner then:

from typing import Any
from typing import Callable
from typing import Dict
from typing import List
from typing import Tuple

And this is an extremely common case!

So while I'm sorry isort can't make this change, I hope you can understand the reasons why, even if they are different from your own preferences, which isort will continue to support via configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants