Closed colindean closed 1 year ago
Can you share the Starlark that triggers this as well?
It looks like you're trying to return a reference to a function somehow? A Builtin is a Go function that is callable from Starlark. I'd like for this module to support returning Callables back to Python but it doesn't at this time.
I introduce a print()
of the final output and tracked it down to basically this:
"slack": {"needs": <built-in method keys of dict value>,
and this is the minimum reproduction:
def stage_slack_notify(stage_names):
return {"name": "slack", "needs": stage_names}
def main(ctx):
build_stages = {"something": [], "something_else": []}
stages = [build_stages] + [stage_slack_notify(build_stages.keys)]
final = {
'version': '1',
'stages': stages,
}
print(final)
return final
Can you spot the error?
Dict.keys()
is a function and I forgot ()
. ๐ PEBKAC.
But I still feel like there's a better way to communicate the error, perhaps by telling exactly what wasn't able to be converted, with some path to it if possible.
Keeping track of the path to the value would be doable but maybe kinda ugly. I think we'd have to add a path
parameter to every function in starlark_to_python.go and have starlark[Dict|Tuple|Set|List]ToPython
append keys to it before passing it along to the next function.
I can't tell which property of the final output of my Starlark script is not convertible.
Test code:
The test code is working with simple dictionaries so it might be something else fancier I'm (unknowingly) doing that's not resolving to something convertible.