-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 should always explode multiline collection literals #152
Comments
TBH I am highly sympathetic to this argument. |
This turns out to be a common complaint. The current behavior is pretty core to how Black formats all bracket content. This includes collection literals (tuples, lists, sets, dicts), function calls and function signatures. Since we probably already have to bail on this behavior because of isort, it makes sense to evolve Black such that:
What do you think? (cc @hynek) I lament that it will complicate my code but that's my problem. |
I'm just here to ruin your day with complexity ;) |
Well, as you know, I’m a big fan of exploding everything. :) I’m very bad at reading long lines (especially with dicts). |
The import part of this is now done. For collection literals I have to figure out a consistent way of doing it. |
Just to verify, this covers: env = Environment(
loader=FileSystemLoader(dir_name),
extensions=[
- "jinja2.ext.i18n",
- "warehouse.utils.html.ClientSideIncludeExtension",
+ "jinja2.ext.i18n", "warehouse.utils.html.ClientSideIncludeExtension"
],
cache_size=0,
) Right? |
Yup. |
Operating system: macOS
Python version: 3.6.1
Black version: 18.4a2
Does also happen on master: Yes
After running black, I've gotten code formatted like:
While I understand the intention is for a sequence that can fit on one line to be on one line, this list here obviously can't fit on one line (it's been broken over 3 lines!) but it can only fit onto one line when you remove part of the syntax that makes it a list/tuple/whatever.
I think that it would be easier to read if the detection of a multi-line sequence was more aggressive, either it should all fit onto one line, or it should be formatted like:
The text was updated successfully, but these errors were encountered: