fresh-cat-90827
12/05/2022, 5:00 PMfresh-cat-90827
12/05/2022, 5:00 PM$ ./pants dependencies helloworld/translator/translator_test.py
//:reqs#pytest
helloworld/translator/translator.py:lib
which is expected (translator_test.py
imports translator.py
and pytest
).
Now, what if I'd like to say that translator_test.py
only depends on a particular target and doesn't depend on the imports that take place in that file? With the overrides, I can do:
python_tests(
name="tests",
overrides={
"translator_test.py":
{
"dependencies": ["helloworld/greet:translations"]
}
}
)
and get:
$ ./pants dependencies helloworld/translator/translator_test.py
//:reqs#pytest
helloworld/greet:translations
helloworld/translator/translator.py:lib
However, would it be possible to discard the first party imports that take place in the translator_test.py
? Or at least be able to distinguish between the inferred dependencies (via `import`s) and dependencies that come from the overrieds
parameter? My ultimate goal is to get:
$ ./pants dependencies helloworld/translator/translator_test.py
helloworld/greet:translations # comes from the `overrides`
polite-garden-50641
12/05/2022, 5:55 PMpolite-garden-50641
12/05/2022, 5:59 PM# pants: no-infer-dep
https://www.pantsbuild.org/docs/reference-python-infer#importsfresh-cat-90827
12/05/2022, 9:40 PMthere is also a directive you can use in the source file.... # pants: no-infer-depthat's the one, I think!
$ PANTS_PYTHON_INFER_IMPORTS=False ./pants dependencies helloworld/translator/translator_test.py
helloworld/greet:translations
fresh-cat-90827
12/05/2022, 9:41 PM