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

long comments cause needless optional parentheses #374

Closed
matejcik opened this issue Jun 22, 2018 · 2 comments
Closed

long comments cause needless optional parentheses #374

matejcik opened this issue Jun 22, 2018 · 2 comments
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. T: enhancement New feature or request

Comments

@matejcik
Copy link

Operating system: Linux
Python version: 3.6
Black version: 18.6b4
Does also happen on master: yes

here's a POC:

x = 0  # this comment is so long that i am certain it will soon end up beyond the 88 character limit

reformatted code:

x = (
    0
)  # this comment is so long that i am certain it will soon end up beyond the 88 character limit

Not sure what is the desired result here, but this is certainly not it :) Probably just leave the line alone in case where the "multilining" doesn't help? There seems to be a behavior where simple assignment is left alone even if too long.

Similar thing happens when the assigned value is long and a relatively short comment pushes it over the edge.

OTOH what I'd actually want in this case is to keep the assignment but push the comment to the next line - or somewhere else. This is the wrong formatting result, but it does notify me that human intervention is needed, which is good.

@ambv
Copy link
Collaborator

ambv commented Jun 22, 2018

Agreed this is suboptimal. We already omit formatting when the target of an assignment is not splittable and too long even on its own line. We should do the same for comments that are in the same situation.

@ambv ambv added T: enhancement New feature or request F: parentheses Too many parentheses, not enough parentheses, and so on. labels Jun 22, 2018
@ambv ambv added the stable label Mar 3, 2020
@felix-hilden
Copy link
Collaborator

This does not happen anymore (playground). For comment splitting please follow #1713 and #2289. I'll close this issue now!

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

3 participants