elegant-florist-94385
07/25/2024, 5:27 PMextra_env_vars
conditions. So I'm using parametrize (which is straightforward and makes sense). However, this seems to cause some target/dependency issues:
I have a test file test_file_a.py
which also contains a utility function. test_file_b.py
wants to use this utility function, so it imports test_file_a.py
Now, because of parametrize, I have warnings like this:
11:17:39.94 [WARN] The target backend/test/integration/test_file_b.py:tests@extra_env_vars=config2 imports `test.integration.test_file_a.utility_function`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['backend/test/integration/test_file_a.py:tests@extra_env_vars=config1', 'backend/test/integration/test_file_a.py:tests@extra_env_vars=config2'].
Please explicitly include the dependency you want in the `dependencies` field of backend/test/integration/test_file_b.py:tests@extra_env_vars=config1, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.
Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to <https://www.pantsbuild.org/2.21/docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies>.
Is there some way I can get pants to understand that a particular parametrized target should use the equivalently parametrized target as its dependency?
Long term, I think the ideal thing is to get the utility functions out of the test files and into a common python_source()
that doesn't get parametrized, but in the meantime, is there some way to get pants to understand?steep-eve-20716
07/25/2024, 5:31 PMelegant-florist-94385
07/25/2024, 5:35 PMsteep-eve-20716
07/25/2024, 5:36 PMsteep-eve-20716
07/25/2024, 5:37 PM