Skip to content

Use parentheses in: a = b == c #449

@njsmith

Description

@njsmith

Some changes black wants to make to my code:

-on_windows = (os.name == "nt")
+on_windows = os.name == "nt"
-        currently_registered = (fd in self._registered)
+        currently_registered = fd in self._registered

The parentheses were originally there to aid readability, by emphasizing that RHS of the = is an unusual-but-valid self-contained expression and not, like, a chained assignment or comprehension or something. Perhaps black should preserve, or even add, parentheses in cases like this? I guess the in case is more debateable, but the = == case is really really easy to misread.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: parenthesesToo many parentheses, not enough parentheses, and so on.T: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions