How can I ignore SonarQube warnings in Python code
In Java, I can use
@SuppressWarnings("squid:S1166")
Where the ID is the SonarQube rule ID. But what syntax should I use in Python?
I've tried
# noinspection python:S1313
but it didn't work.
To be clear, I'm looking for a solution in python code. NOT JAVA.
I believe the only syntax supported for Python (assuming it is supported) is the NOSONAR comment, so #NOSONAR
or # NOSONAR
at the end of the line where you want to ignore issues.
Unfortunately, this is a global issue suppression: it kills all issues on the line, not just those from a specific rule.
23 July 25 Edit: Development has been completed on this and it is set to be deployed to SonarQube Cloud imminently. It will be part of SonarQube Server 2025.4, and part of SonarQube Community Build 25.8.
Not only has raw NOSONAR
been implemented, but "fancy" use is supported as well: # NOSONAR (S1234,S789) “my special reason”
The announcement notes that noqa
is supported now as well. ;-)