Language: Python 3.10
Rule: S1854 - Unused assignments should be removed
IDE: IntelliJ 2024.2.3 with Sonarlint Plugin 10.10.0.79575
The linter do not take this rule into account when there is a try-except block:
def example():
try:
do_something = "hello world"
except ValueError:
pass
if "this" == "that":
test = "some value"
test = "other value"
print(test)
Removing the try-except block will correctly identify the issue with the assignment.