Why is pant having issues inferring this `.api_mod...
# general
p
Why is pant having issues inferring this
.api_models
import (I'm getting "Pants cannot infer owner" warning): https://github.com/st2sandbox/st2/blob/pants/pylint_plugins/api_models_test.py#L25 Here
/pylint_plugins
is a source root, and
/pylint_plugins/api_models_test.py
is using a relative import for
/pylint_plugins/api_models.py
:
from . import api_models
Does the dep inference not like relative imports?
1
e
I mean, you can test that hypothesis in a heartbeat - right?
p
Yeah. It turns out pants needed one style of imports, because it added that directory on the PYTHONPATH, but running pytest directly used a different import (w/o the dir on PYTHONPATH). When the dir is on PYTHONPATH, I have to do
import api_models
, when it is not on PYTHON_PATH, I have to do
from . import api_models
. I did a
try/except ImportError
to do both.