This rule raises an issue when the walrus operator is used in a way which makes the code confusing, as described in PEP 572.
The walrus operator := (also known as "assignment expression") should be used
with caution as it can easily make code more difficult to understand and thus maintain. In such case it is advised to refactor the code and use an
assignment statement (i.e. =) instead.
Reasons why it is better to avoid using the walrus operator in Python:
Avoid using the walrus operator for the cases when it is not mandatory.
v0 = (v1 := f(p)) # Noncompliant: Use an assignment statement ("=") instead; ":=" operator is confusing in this context
f'{(x:=10)}' # Noncompliant: Move this assignment out of the f-string; ":=" operator is confusing in this context
v0 = v1 = f(p)
x = 10
f'{x}'