Is there supposed to be some protection against mo...
# general
f
Is there supposed to be some protection against more than one target owning a source? Somehow I got it into my head that there was an error that came up when that happened, but it seems easy to to make two targets own the same source (forgive me for using BUILD files in my root dir, I'll repent soon, I promise):
Copy code
❯ ./pants list aiven/admin/__init__.py
//aiven/admin/__init__.py:../../aiven
//aiven/admin/__init__.py:../../fake-target
Was there ever protection against this? Is this considered an okay situation to be in?
b
It's A-OK to Pants. In inference scenarios you should get a warning if something matches the file, as it can't infer the right owner. Other than that, go nuts?
h
Pants doesn't have any automated protection for this—other than dep inference failing—because it indeed can be desirable to do Also note that Pants 2.10 is the first time that dependency inference can accommodate >1 target for the same source file or 3rd-party requiremenet: specifically if they each have a different
resolve
for the multiple resolves (lockfiles) feature. Like
utils.py
working with both
data-science
and
web-app
resolves. We may want to expand that dependency inference accomodation to more fields in the future
f
oh hmmm
h
Also related: Pants 2.11 faciliates creating multiple targets with a new
parametrize()
builtin
Copy code
python_source(
   name="utils",
   source="utils.py",
    resolve=parametrize("a", "b"),
)
This creates two targets:
dir:utils&resolve=a
and
dir:utils&resolve=b