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

Don't squeeze hanging comments to the left #20

Closed
grantjenks opened this issue Jan 15, 2021 · 3 comments · Fixed by #31
Closed

Don't squeeze hanging comments to the left #20

grantjenks opened this issue Jan 15, 2021 · 3 comments · Fixed by #31
Assignees
Labels
formatting-idea Formatting ideas
Milestone

Comments

@grantjenks
Copy link
Owner

Let's consider not squeezing hanging comments to the left, e.g. not doing this:

-    def _coerce(self, value, default: Optional[int] = 0) -> Optional[int]:      # type: ignore[no-untyped-def]
+    def _coerce(self, value, default: Optional[int] = 0) -> Optional[int]:  # type: ignore[no-untyped-def]

And here's an egregious example from flufl.i18n:

-    aqua = 'aardvarks'                          # noqa: F841
-    blue = 'badgers'                            # noqa: F841
-    cyan = 'cats'                               # noqa: F841
+    aqua = 'aardvarks'  # noqa: F841
+    blue = 'badgers'  # noqa: F841
+    cyan = 'cats'  # noqa: F841

The latter is definitely less readable.

@grantjenks
Copy link
Owner Author

Here's what black does for long arg lists:

def test(arg1001, arg1002, arg1003, arg1004, arg1005, arg1006, arg1007, arg1008, arg1009, arg1010):     # noqa
    pass

to

def test(
    arg1001,
    arg1002,
    arg1003,
    arg1004,
    arg1005,
    arg1006,
    arg1007,
    arg1008,
    arg1009,
    arg1010,
):  # noqa
    pass

@grantjenks
Copy link
Owner Author

It would be nice to preserve the column of the original comment.

@grantjenks grantjenks added the formatting-idea Formatting ideas label Jan 15, 2021
@grantjenks
Copy link
Owner Author

+1'ing again after formatting grantjenks/python-diskcache. Hanging comments are necessary and the jagged pattern hurts my eyes.

@warsaw warsaw added this to the 0.6.0 milestone Jan 22, 2021
@warsaw warsaw self-assigned this Jan 23, 2021
warsaw added a commit that referenced this issue Jan 23, 2021
We're close but not quite there yet!

```
error: cannot format /tmp/bar.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /var/folders/dg/2gcv7qh1141dfc13k7kbty7w000slb/T/blk_81rqaiyh.log
Oh no! 💥 💔 💥
1 file would fail to reformat.
```

Closes #20
warsaw added a commit that referenced this issue Jan 27, 2021
Preserve whitespace before hash mark on hanging comments

Closes #20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatting-idea Formatting ideas
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants