https://pantsbuild.org/ logo
#development
Title
# development
h

hundreds-father-404

04/11/2022, 11:26 PM
@witty-crayon-22786 should we be applying something like https://github.com/pantsbuild/pants/pull/14788 to command line specs?
i used this diff
Copy code
diff --git a/src/python/pants/util/BUILD b/src/python/pants/util/BUILD
index 76d0a50a8..660377f23 100644
--- a/src/python/pants/util/BUILD
+++ b/src/python/pants/util/BUILD
@@ -3,4 +3,7 @@
 
 python_sources()
 
-python_tests(name="tests")
+python_tests(
+    name="tests",
+    interpreter_constraints=parametrize(py39=["==3.9.*"], py310=[">=3.9"]),
+)
./pants test src/python/pants/util:tests
fails and suggest instead
src/python/pants/util:tests@interpreter_constraints=py39
and
src/python/pants/util:tests@interpreter_constraints=py310
That is surprising to me. It is a moved field, so I would expect only the original target generator to exist
(lol this interaction is so confusing)
w

witty-crayon-22786

04/11/2022, 11:29 PM
each of
src/python/pants/util:tests@interpreter_constraints=py39
and
src/python/pants/util:tests@interpreter_constraints=py310
… are target generators, yea. they depend on the files that they generated
h

hundreds-father-404

04/11/2022, 11:30 PM
So, the dependencies field should be able to reference either of those target generators as a alias for each generated target. Or, thanks to your PR, we also have an affordance that you can use the original target generator without parameters
w

witty-crayon-22786

04/11/2022, 11:30 PM
but… yes. it might make sense to have CLI specs expand to all matching parametrized targets. https://github.com/pantsbuild/pants/pull/14788 expanded to exactly one.
👍 1
h

hundreds-father-404

04/11/2022, 11:31 PM
I think that it would remove some confusion
My vague understanding is that we are giving you several degrees of specificity
1) everything 2) everything for a particular param 3) one generated target
w

witty-crayon-22786

04/11/2022, 11:32 PM
My vague understanding is that we are giving you several degrees of specificity
on the CLI, yea… the affordance in BUILD files still resolves to exactly one matching target.
👍 2
h

hundreds-father-404

04/11/2022, 11:33 PM
It would help me with the update I am doing to the docs on parameterization. I would like to be able to claim that you can generally refer to the original target, and things will still work just be less precise
w

witty-crayon-22786

04/11/2022, 11:33 PM
i’ll create a ticket.
❤️ 1
h

hundreds-father-404

04/11/2022, 11:35 PM
ah yeah cool, this applies to atom targets too:
Copy code
diff --git a/src/python/pants/util/BUILD b/src/python/pants/util/BUILD
index 76d0a50a8..091736175 100644
--- a/src/python/pants/util/BUILD
+++ b/src/python/pants/util/BUILD
@@ -3,4 +3,8 @@
 
 python_sources()
 
-python_tests(name="tests")
+python_test(
+    name="test",
+    source="strutil_test.py",
+    interpreter_constraints=parametrize(py39=["==3.9.*"], py310=[">=3.9"]),
+)
Copy code
$ ./pants test src/python/pants/util:test
The address `src/python/pants/util:test` was not generated by the target `src/python/pants/util:test`, which only generated these addresses:

  * src/python/pants/util:test@interpreter_constraints=py39
  * src/python/pants/util:test@interpreter_constraints=py310
w

witty-crayon-22786

04/11/2022, 11:45 PM
h

hundreds-father-404

04/11/2022, 11:50 PM
OK, parameterization section is rewritten. Feedback welcomed https://www.pantsbuild.org/v2.11/docs/targets#parametrizing-targets
I am still trying to figure out what to do with the warning box I updated the warning box too herehttps://www.pantsbuild.org/v2.11/docs/targets#source-and-sources-field
I think that I'm not going to touch the overrides field in docs... too niche and confusing
w

witty-crayon-22786

04/14/2022, 8:15 PM
looks great. i’ll break out a tiny section to clarify the
```Generally, you can still use
example:tests
without the
@
suffix as an alias to all the
created targets.```
bit
🙌 1