Skip to content

Regression: Unnecessary parens with unary minus operator #1041

@JelleZijlstra

Description

@JelleZijlstra

I noticed this change while testing Black master on our codebase:

             step_adjustments["ScalingAdjustment"] = min(
-                scaling_adjustment, -self.get_max_weight()
+                scaling_adjustment, -(self.get_max_weight())
             )

Also (more justifiable):

-        -2 ** 32,
-        -2 ** 48,
-        -2 ** 63,
+        -(2 ** 32),
+        -(2 ** 48),
+        -(2 ** 63),

I think the first example is a bug. A simpler repro:

$ black -c '-self.x()'
-(self.x())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions