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

Add option to avoid breaking a single word into a new line #241

Open
ThiefMaster opened this issue Jun 14, 2023 · 1 comment
Open

Add option to avoid breaking a single word into a new line #241

ThiefMaster opened this issue Jun 14, 2023 · 1 comment
Labels
C: stakeholder Relates to docformatter stakeholder requested behavior P: enhancement Feature that is outside the scope of PEP 257 U: low A relatively low urgency issue

Comments

@ThiefMaster
Copy link

ThiefMaster commented Jun 14, 2023

I don't know in which formatter I saw this (might have been ruff but can't find it there anymore), but one of them has this really nice feature that minor max-line-length violations are acceptable, if wrapping would result in ugliness. In particular this means that it will
not auto-wrap a comment if the next line would contain just one word. It would either wrap earlier (to have 2-3 words in the new line) or accept that the line will be slightly longer than the usual maximum.

@github-actions github-actions bot added the fresh This is a new issue label Jun 14, 2023
@weibullguy weibullguy added P: enhancement Feature that is outside the scope of PEP 257 C: stakeholder Relates to docformatter stakeholder requested behavior and removed fresh This is a new issue labels Jun 14, 2023
@github-actions github-actions bot added the U: low A relatively low urgency issue label Jun 14, 2023
@electric-coder
Copy link

electric-coder commented Jul 22, 2023

I don't know in which formatter I saw this

It was likely the 10% line-length rule from Black:

Line length

(...) Black defaults to 88 characters per line, which happens to be 10% over 80.

(...) Black will try to respect that. However, sometimes it won’t be able to without breaking other rules. In those rare cases, auto-formatted code will exceed your allotted limit.

The problem is if you're setting --line-length = 88 Black will still give you a few characters extra, but Flake8 will never be happy with the result and will trigger warnings. Black recommends using flake8-bugbear but flake8 is an order of magnitude more popular.

It would either wrap earlier (to have 2-3 words in the new line)

There should be a style guide quoted backing up this option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: stakeholder Relates to docformatter stakeholder requested behavior P: enhancement Feature that is outside the scope of PEP 257 U: low A relatively low urgency issue
Projects
None yet
Development

No branches or pull requests

3 participants