Python logoPython/
PTC-W0066

Use of `=+` / `=-` looks ambiguousPTC-W0066

Minor severityMinor
Anti-pattern categoryAnti-pattern

Operator pair (=+ / =+) used without space after = looks ambiguous. This looks like a typo for += / -=.

Operator pair (=+ or =-) don't produce the same result as the reverse operator (+= or -=).

If you wanted to make the operand negative, consider inserting a space after the assignment operator like this x = -5.

This may also be a typo, where you actually meant something like x += 1.

Not Preferred

total = 10
count = 5
total =+ count # total = 5, Addition assignment doesn't take place
loss =- count # loss = -5, Not clear whether intent is to assign the inverse or perfrom Subtraction assignment

Preferred

total = 10
count = 5
loss = 10

# When + / -  is intentional after `=`
total = count  # total = 10
loss = -count  # loss = -5 : Expected result is clear

# If the operator was a typo:
total += count  # total = 15
loss -= count  # loss = 5

NOTE: In this case, DeepSoure autofixes the issue by changing =+ to += and =- to -= respectively.Please do not autofix this issue if +/- after = is intentional.