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

feature_request(comments): wrap comments #181

Closed
Kristinita opened this issue Apr 30, 2018 · 3 comments
Closed

feature_request(comments): wrap comments #181

Kristinita opened this issue Apr 30, 2018 · 3 comments

Comments

@Kristinita
Copy link

Kristinita commented Apr 30, 2018

1. Summary

It would be nice, if comments would be wrapped to next lines.

2. Argumentation

Citation from Black description:

You can also increase it, but remember that people with sight disabilities find it harder to work with line lengths exceeding 100 characters. It also adversely affects side-by-side diff review on typical screen resolutions. Long lines also make it harder to present code neatly in documentation or talk slides.

All of the above can be attributed to the comments.

3. Configuration

Example: I have a file SashaBlack.py:

# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

4. Steps to reproduce

black SashaBlack.py

or

black --line-length 120 SashaBlack.py

5. Expected behavior

# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
# aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
# Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
# occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

6. Actual behavior

No changes.

D:\SashaDemoRepositories\SashaBlackDebugging>black --line-length 120 SashaBlack.py
D:\SashaDemoRepositories\SashaBlackDebugging\SashaBlack.py already well formatted, good job.

Thanks.

@ambv
Copy link
Collaborator

ambv commented Apr 30, 2018

I absolutely agree with you that it would be great if Black did that.

However, there is a major snag: many comments require verbatim formatting. They might have to be machine parseable, they might present code or data (especially commented out code!), and so on.

There is no markup that would unambiguously state that a given comment is safe to be reformatted, so we would need to resort to heiristics.

In consequence, if Black reformatted comments it would inevitably destroy information sometimes. That's a breach of trust that I'm not willing to risk.

@ambv ambv closed this as completed Apr 30, 2018
@Kristinita
Copy link
Author

@ambv , what do you think about option --format-comments?

Thanks.

@ambv
Copy link
Collaborator

ambv commented Apr 30, 2018

I hate options, as you probably figured out from the README. More importantly, such an option is too binary. Most of the time the answer to "Should I reformat this comment?" is: it depends.

For example, a # type: ignore comment has to stay on the line it was originally put on and cannot be split over multiple lines.

An option like you're suggesting would inevitably be insufficient and lead to requests for more configurability and intelligent heuristics.

As I said in my first response, I would absolutely love to have this feature but doing it properly is sadly out of scope for a simple project like mine. I hope you don't treat my cautious pessimism here as dismissive.

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

2 participants