Why does `importlib.import_module("a.module")` go...
# development
b
Why does
importlib.import_module("a.module")
go in the "string imports" bucket, but
__import__("a.module")
not?
Is it just harder to identify because you'd techincally have to look for: •
import importlib
...
importlib.import_module
from importlib import import_module
...
import_module
from importlib import import_module as imp_mod
...
imp_mod
h
it should make no difference. String imports literally just analyze every string using Python's AST Are you sure it's
a.module
in both cases? You may need to play with this option: https://www.pantsbuild.org/docs/reference-python-infer#section-string-imports-min-dots
b
I'm asking just because I'm using this as prior art for another feature 🤓
❤️ 1
h
Are you saying that we treat
__import__
the same as
import
, so its arg is treated like a literal import instead of a string import?
I forget how that code goes
h
Ah right
I think we did that because it's commonly used in
__init__.py
files
So I don't think there's a strong reason we didn't do the same for
importlib.import_module
other than it's not commonly used
If there was a need, those could be considered "real" imports
b
I assume the only case it'd be catching is either string imports are off, or the module name doesn't meet the min dots requirement