`this expression does not have a "__getitem__" method` for Python `ModuleType.__path__`

  • What language is this for? Python
  • Which rule? python:S5644
  • Why do you believe it’s a false-positive/false-negative? Python doc says __path__ is a list
  • Are you using
    • SonarLint - which IDE/version? SonarLint v3.16.0 on VS Code v1.76.2
      • in connected mode with SonarQube or SonarCloud? connected to SonarCloud
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
from importlib import import_module

import_module('importlib').__path__[0]

Hello @ppena-LiveData,

Thank you for reporting this false positive.
I created the following ticket to fix it.

Cheers,
Guillaume