-
-
Notifications
You must be signed in to change notification settings - Fork 584
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
black and isort conflict unless line length copy/pasta #1743
Comments
Hi @Akuli, I could see why you would want this! However, I think simply setting them for both is the better option. The profile will give you the same default as black's so you only have to do this, if you want a custom line length. isort can't reasonably find all locations of blacks configuration parameters now and to the future. Doing some level of magic pulling it in I feel like would set up the project and users for confusing issues, as it would sometimes pick it up and sometimes not, and even worse could lead to weird environment dependent issues that break in CI but work locally or vice versa. |
I agree that this may be too fragile to actually implement, but in practice, using black's configuration isn't quite that difficult. If someone has isort configuration in pyproject.toml, then they very likely configure black in pyproject.toml as well. If we never touch any other black config files, then I don't really see how exactly it could "break in CI but work locally or vice versa". |
Right, but that's only one possible way someone could have that implemented. They could instead:
And those are just a few of the complications I can think of off the top of my head with just the current implementation of black. Who knows what could happen in the future! It's much better for the project to require a very small duplication to set the line length combination, than to try to be magical here, with a ton of asterisks that both us and users need to think about IMHO.
Some projects move around configs or create them dynamically either in (usually) the CI or sometimes the local step. People don't tend to assume that applications are cross reading configs, so when one application does start doing that, it can cause breakages. One example of what this could look like: A project uses pre-commit for local usage (and sets the line length manually in the command invocation). Now all the sudden isort has the "wrong" line-length when ran locally (because it can't read from precommit command invocation in any sustainable way), but correct when ran from CI. These kind of things cause a ton of pain both for users and the project because they can be hard to track down and explain. And often times the people who set up the weird setup are not the users of the tool that are then trying to understand why it's not working consistently. |
A long wall of text. I didn't read it, but I'm convinced! |
pyproject.toml:
isort wants:
black wants:
You can copy/paste the same line length to both configs but it would be nice if
profile = "black"
would read it from black's config. Or is that not how profiles work?The text was updated successfully, but these errors were encountered: