March 10, 2023, 10:10am
Operating system: Ubuntu 20.04.5 LTS x86_64
IDE name and flavor/env: vscode and PyCharm
I get this warning when checking the return value of
pydoc.locate not to be None:
Remove this identity check; it will always be True.sonarlint(python:S5727)
But this is a false positive as the
None is a subtype of
object, and the
pydoc.locate could return a None if the object not exits (see:
To reproduce you can use this dummy function:
res = pydoc.locate("modul.Obj")
if res is not None: # <--- Remove this identity check; it will always be True.sonarlint(python:S5727)
March 10, 2023, 10:58am
What version of SonarLint are you using?
March 10, 2023, 11:56am
VS Marketplace Link: SonarLint - Visual Studio Marketplace
@smallSwed and sorry for the late reply,
Indeed, the rule raises a false positive in this case. Thank you for reporting it!
I created the following ticket to fix this.