Python 3-related code smells still reported after setting sonar.python.version to 2.7

I would appreciate some clarification regarding the sonar.python.version setting.

We have a project with sonar.python.version set (via to 2.7 as per the documentation.

The analysis nevertheless highlights some code smells related to Python 3, for example python:PrintStatementUsage (The “print” statement should not be used).

  • Is this behavour expected, or does this suggest my sonar.python.version does not get through to the analyser? (although I don’t see the warning regarding it not being set…)

  • How can we tell SonarQube this is Python 2.7 code and Python 3 checks should not be performed?

Many Thanks

PS We are using SonarQube

Hi @m2427 ,

Thanks a lot for raising this point. I created this ticket to keep track of the FP you reported.

Currently, sonar.python.version impact is quite limited and it’s only used to build the correct standard library and symbols inside the Python analyzer.

We don’t use it (yet) to activate / deactivate rules, although this is our plan in the long term.

Regarding the specific rule PrintStatementUsage, this is an old rule and it probably makes sense to remove it from the default quality profile. We will discuss this internally.

Indeed, if sonar-python-version could affect the applied rulesets, this would be very helpful.

Thank you very much for clarifying.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.