FP sonarlint(python:S1481)

  • What language is this for? Python 3.10
  • Which rule? S1481
  • Why do you believe it’s a false-positive/false-negative? Variable reported as unused is used
  • Are you using
    • SonarLint 4.5.1 - which IDE/version?
      Visual Studio Code
      Version: 1.88.1
      Commit: e170252f762678dec6ca2cc69aba1570769a5d39
      Date: 2024-04-10T17:34:12.840Z
      Electron: 28.2.8
      ElectronBuildId: 27744544
      Chromium: 120.0.6099.291
      Node.js: 18.18.2
      V8: 12.0.267.19-electron.0
      OS: Linux x64 6.5.0-28-generic
      • in connected mode with SonarQube or SonarCloud? No
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
def add_to_dict(values: dict):
    values |= dict(b=2) # Remove the unused local variable "values".sonarlint(python:S1481)

if __name__ == '__main__':
    d = dict(a=1)
    print("Before:", d)
    add_to_dict(d)
    print("After:", d)

Hello,

I have successfully reproduced the issue and created SONARPY-1814 to address it.

Have a nice day,
Ghislain

1 Like