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

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.

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!

2 Likes

And thank you for this excellent tool.

2 Likes