I'm writing a pylint checker and I need to differentiate between an import that is a sibling import of a package and an import of a function or class.
Example of sibling import:
from . import sibling_package
Example of a function import:
from numpy import array
The latter example I want to flag, while the former I want to allow, so I need to be able to tell the difference between the two.
I'm currently using:
modspec = importlib.util.find_spec('numpy', 'array')
That returns a ModuleSpec
, but I'm unclear how I can get to the goal of identifying the import array
as a module vs. a function/class. In this example it is a function import, and thus should be flagged.