hey is it possible to request using a generic Targ...
# plugins
f
hey is it possible to request using a generic Target when your object is a child of
Target
e.g.
Copy code
files = await Get(SourceFiles, Target, target)
Copy code
TypeError: Invalid Get. The third argument ... must have the exact same type as the second argument, <class 'pants.engine.target.Target'>, but had the type <class 'pants.backend.python.target_types.PythonTestTarget'>.
the code I have works in the goal rule, I just wanted to tidy up and extract into a separate rule. I know vaguely about the UnionRule, but I am not sure it can help me as I don't want to create new classes and register with
@union
, I want to union existing classes which are not decorated with
@union
and seems to be unusable. Does that make any sense?
1
c
can the type of
target
vary, or is it always going to be a
PythonTestTarget
?
f
it will vary, like 4-5 types (python_source, python_test, python_test_utils, plus a few custom ones)
maybe I could cheat and pass the address of a target and then do
target = await Get(Target, Address, address)
in the rule 😕
c
besides unions, there’s also a lot of wrapper classes around to solve issues like these.. more on the returning side of things I beleive, but.. like WrappedTarget for instance.
f
yes,
await Get(Targets, Addresses([address]))
works 🙂
👍 1