Python matrix product operator @ with equal operands triggers "python:S1764"

sonarlint
(José Luis Esteban) #1

Using the latest SonarLint version provided by PyCharm.

When using Python 3.5 matrix operator in an expression of the form a @ a, SonarLint detects major bug python:S1764: Identical expressions should not be used on both sides of a binary operator.

According to PEP 456, there should be no problem in such an expression, unless operand dimensions are incompatible, but that’s not something SonarLint could statically analyze.

(Pierre-Yves Nicolas) #2

Hi!

You’re right, this is a false positive.
We should exclude the @ operator from that rule, the same way we already exclude the multiplication operator.
Ticket created : SONARPY-332

Thanks a lot for your feedback!

1 Like
(José Luis Esteban) #3

And thank you for this excellent tool.

1 Like