:test_tube: Have you ever wanted to split off some...
# development
b
๐Ÿงช Have you ever wanted to split off some part of your
@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:
Copy code
@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
๐Ÿ“ฃ 2
๐Ÿ™‡ 1
๐Ÿ™Œ 2
๐Ÿ’ฅ 1