Skip to content

long comments cause needless optional parentheses #374

@matejcik

Description

@matejcik

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: parenthesesToo many parentheses, not enough parentheses, and so on.T: enhancementNew feature or request
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions