I can't seem to get a rule running `Get` to call a...
# plugins
f
I can't seem to get a rule running
Get
to call a rule without parameters ๐Ÿงต
โœ… 1
Copy code
@dataclass
class Dummy:
    pass


@rule
async def foo() -> Dummy:
    return Dummy()


@goal_rule
async def goal_dummy() -> DummyGoal:
    result = await Get(Dummy, {})
gives me
Copy code
[ERROR] Invalid Get. Because you are using the shorthand form Get(OutputType, InputType(constructor args), the second argument should be a constructor call, like `MergeDigest(...)` or `Process(...)`. Failed for Get(Dummy, <class 'ast.Dict'>) in .../rules.py.
b
If you don't need it async on-demand I think you can just make it a param of the requesting rule?
Copy code
@goal_rule
async def goal_dummy(dummy: Dummy) -> DummyGoal:
    ...
f
yes, I can, but there is conditional logic, so I don't want always call this rule
b
Ah yeah, ok carry on ๐Ÿ™‚
I must be doing something wrong!
b
The way I've seen this is to make a dummy request class and use that
See
AllTargetsRequest
+
AllTargets
f
the way I've solved it is by adding an unused input parameter to the rule just to be able to do
await Get(OutputClass, str, "")
but it's not pretty ๐Ÿ™‚
h
@fresh-cat-90827 what Pants version are you on? This is a new feature. I think only 2.15+
f
aaah
sorry, 2.14, let me try the latest
still getting
Copy code
[ERROR] Could not resolve type `<ast.Name object at 0x7fc024bd6460>` in top level of module project_version.rules defined in .../rules.py:103
line 103:
result = await Get(Dummy, {})
tried
"2.15.0rc1"
and
"2.16.0.dev3"
h
do you define the type above the Get call?
f
oh lol that was the issue ๐Ÿ™‚
had to move the dataclass definition above the goal rule
๐Ÿ‘ 1