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

Auto-parenthesize multipart strings #1416

Open
JelleZijlstra opened this issue May 16, 2020 · 0 comments
Open

Auto-parenthesize multipart strings #1416

JelleZijlstra opened this issue May 16, 2020 · 0 comments
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. T: enhancement New feature or request

Comments

@JelleZijlstra
Copy link
Collaborator

With Black's new ability to split overly long strings, it would be nice if it would also put parentheses automatically in at least some places.

In this diff:

     fix_fstab_commands = [
-        "grep -q /dev/xvdd /etc/fstab || sed -i '2i/dev/xvdd /mnt auto defaults,nofail 0 2' /etc/fstab",
-        "grep -q /dev/nvme1n1 /etc/fstab || sed -i '2i/dev/nvme1n1 /mnt auto defaults,nofail 0 2' /etc/fstab",
+        "grep -q /dev/xvdd /etc/fstab || sed -i '2i/dev/xvdd /mnt auto defaults,nofail"
+        " 0 2' /etc/fstab",
+        "grep -q /dev/nvme1n1 /etc/fstab || sed -i '2i/dev/nvme1n1 /mnt auto"
+        " defaults,nofail 0 2' /etc/fstab",
     ]

It's hard to see in the output where each of the two commands start (you have to look for a tiny comma in the middle). It would look better if there were parens around the two commands, so they are clearly visually separated.

We already know to do this in other contexts:

-        help="Import functions for performance analysis. Can't be used with other startup script options.",
+        help=(
+            "Import functions for performance analysis. Can't be used with other"
+            " startup script options."
+        ),
@JelleZijlstra JelleZijlstra added the T: enhancement New feature or request label May 16, 2020
@ichard26 ichard26 added the F: parentheses Too many parentheses, not enough parentheses, and so on. label Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. T: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants