So someone was reviewing a macro I wrote and asked...
# general
c
So someone was reviewing a macro I wrote and asked something along the lines of "do all docker_image targets have `name`s?" Neither
pants help-advanced docker_image
nor
pants help-advanced target
mention a
name
field. But I'm pretty sure targets have names? From the code it looks like the "answer" is: ā€¢ (A) All `pants.engine.target.Target`s have a name, but it maybe an implicit one. ā€¢ (B) but! In the case of macros, when you are looking at kwargs said implicit name would not yet be available. So I think I've answered my own question. But should I have been able to answer (A) from
help
and not grepping the pants source code?
c
You did šŸ˜‰ generally, target addresses are described here https://www.pantsbuild.org/v2.16/docs/targets#target-addresses and states about the same as your conclusion
in a macro, if you want to know what the implicit name would be, you can always use
build_file_dir().name
šŸš€ 1