bitter-ability-32190
04/08/2022, 1:20 PM@rule
which has await Get
in it, but didn't want to go through the hoops of a dedicated @rule
?
โก Behold, the mighty @rule_helper
. โก
Does what it says on the tin! Allows you to split some code off of your @rule
and await Get
in it without the overhead of another rule.
Example:
@rule_helper
async def _collect_thingamabobs(x, y, z):
a = await Get(A, B, x)
if y:
a += await Get(C, D, z)
return a
@rule
async def my_rule(...):
...
a = await _collect_thingamabobs(x, y, z)
....
Code: https://github.com/pantsbuild/pants/blob/f43b0b92931c63509459f1113f7ca1ee34946225/src/python/pants/engine/rules.py#L282