Operating system: Ubuntu 18.04.1 LTS
Python version: Python 3.6.7
Black version: 18.9b0
Does also happen on master: as of 2018-12-20T09:32, yes.
(as per my tweet: https://twitter.com/llanga/status/1075484480436080640 )
The code
-2**8
blacks to
-2 ** 8
I think this is misleading because the grammar reduction rules mean that the code actually parses as -(2**8).
The result of this code, however you format it, is -256, not 256.
I'm not sure what to suggest. Perhaps _not_ altering the space around **?
Though I can see that almost any suggestion will be controversial.
Maybe we should insert parentheses when the unary negation operator applies to more than just a literal (so -(2 ** 8)).
Indeed, assert -16 == -2 ** 4 is looks pretty weird!
Most helpful comment
Maybe we should insert parentheses when the unary negation operator applies to more than just a literal (so
-(2 ** 8)).