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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to ALLOW_MULTILINE_LISTS? #1228

Open
ThereforeGames opened this issue May 13, 2024 · 1 comment
Open

Is there a way to ALLOW_MULTILINE_LISTS? #1228

ThereforeGames opened this issue May 13, 2024 · 1 comment

Comments

@ThereforeGames
Copy link

ThereforeGames commented May 13, 2024

Hi,

Similar to ALLOW_MULTILINE_DICTIONARY_KEYS, I would like YAPF to preserve the formatting of list items that have been declared on individual lines, e.g.

def ui(self, gr):
  return [
	  gr.Textbox(label="Conditional statement 馃、 my_var", max_lines=1),
	  gr.Dropdown(label="Evaluation method 馃、 _is", choices=["==", "!=", "<", "<=", ">", ">="], value="=="),
	  gr.Checkbox(label="Invert evaluation such that a true statement will return false 馃、 _not"),
	  gr.Checkbox(label="Return true if any one of multiple conditions are true 馃、 _any")
  ]

As far as I can tell, the only ways to achieve this would be to adjust the COLUMN_LIMIT (which would have side effects) or to wrap this block in # yapf: disable / enable comments. Is there a cleaner solution?

Thank you. Love your formatter.

@ThereforeGames
Copy link
Author

ThereforeGames commented May 13, 2024

Oops, just noticed this is a dupe of #1209 (comment) .

The simple workaround there works fine; just add a trailing comma to the list.

Still, I think a dedicated ALLOW_MULTILINE_LISTS option would be ideal, so I'll leave this open as a suggested feature enhancement. It's fairly unintuitive (at least to me) that a trailing comma would bypass the line concatenation rules.

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

1 participant