I believe SonarLint is making overly strong assumptions about the “+” operator, although I am not exactly sure what it is doing. Here is a minrep:
class X():
def __pos__(self):
return None # more complex logic here might sometimes return other types as well
x = +X()
if x is not None: # Remove this identity check; it will always be True. sonarlint(python:S5727)
print(x)
- Operating system: MacOS 13.13.1
- Visual Studio version: 1.84.2
- SonarLint plugin version: 4.3.0
- Programming language you’re coding in: Python 3.10.10
- Is connected mode used: SonarCube 9.7 I think