Skip to content

Commit 237539f

Browse files
committed
fix pants dep inference for pylint_plugins
When pylint_plugins/ is on PYTHONPATH, we cannot use a relative import. We do not add it to PYTHONPATH in the Makefile, so we need the relative import. So, use a try/catch block to support both methods until we can drop the Makefile.
1 parent bd7225e commit 237539f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pants.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ source_plugins = [
174174
]
175175
args = [
176176
# needed in st2* components, runners, packs
177-
"--load-plugins=pylint_plugins.api_models",
177+
"--load-plugins=api_models",
178178
# needed in st2* components, runners
179-
"--load-plugins=pylint_plugins.db_models",
179+
"--load-plugins=db_models",
180180
]
181181

182182
[pytest]

pylint_plugins/api_models_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222

2323
# merely importing this registers it in astroid
2424
# so parse() will use our predicate and transform functions.
25-
from . import api_models
25+
try:
26+
# TODO: remove this once we remove the Makefile
27+
from . import api_models
28+
except ImportError:
29+
# pylint_plugins is on PYTHONPATH
30+
import api_models
2631

2732

2833
def test_skiplist_class_gets_skipped():

0 commit comments

Comments
 (0)