Parse error for Python with statement

SonarQube, SonarScanner, Python Code Quality and Security

Error observed while running the Sonar scanner on Python 3.9 source code:

08:15:10.500 ERROR: Parse error at line 309 column 71:
  305: with pytest.raises(KeyError):
  306:         product["measurements/group1/group2"]
  308:     with (
  -->          patch.object(EmptyTestStore, "__delitem__", return_value=None) as del_method,
  310:         patch.object(EmptyTestStore, "__contains__", return_value=True) as in_method,
  311:     ):
  312:         del product["false_key"]
  313:     del_method

My understanding is that this has been fixed in the Sonar-Python plugin ([SONARPY-860] Parse error on `with` statements with parens - SonarSource) but that this version is not yet available in the SonarQube LTS.

Is it planned to update the SonarQube LTS with regards to this fix?

Hey there.

At this time, we don’t anticipate backporting SONARPY-860 to SonarQube v8.9 LTS. The fix is available starting in SonarQube v9.2 (the latest version if v9.3).

ok. Thanks for the quick reply.