https://pantsbuild.org/ logo
a

aloof-angle-91616

05/09/2020, 9:22 PM
@hundreds-father-404 would we be interested in moving the
.expect_single()
method into
Collection
instead of into
Targets
?
h

hundreds-father-404

05/09/2020, 9:24 PM
Possibly, but it’s important the error message doesn’t change for Targets so I’m not sure how clean it would be to generalize
a

aloof-angle-91616

05/09/2020, 9:24 PM
we could just override it in the subclass maybe
h

hundreds-father-404

05/09/2020, 9:26 PM
That might work. Do you have a particular use case for needing the method elsewhere or this is more general refactoring?
a

aloof-angle-91616

05/09/2020, 9:26 PM
i was just wondering why we chose to require collections for
Addresses
->
Targets
where it seems like everywhere else we just use a
MultiGet
oh ok, it's because we get transitive deps. i'd still like to specialize the case when we only want to request a single target but maybe the idea is that we don't want to allow that. i suppose i can request something less general than
Targets
to get what i want
h

hundreds-father-404

05/09/2020, 9:39 PM
You can request a WrappedTarget, given some Address. The wrapper is necessary to work with the engine using exact types But from a goal rule, that won’t work because the user can specify multiple targets. We used to allow you to request in a goal rule one single target, and it made the graph really difficult to work with. Stu and Greg proposed converting it into a method on the collection class