#List[str] as parameter -> compile error

1 messages · Page 1 of 1 (latest)

delicate whale
#

If one of my @function parameters is of type List[str] I get a big compile error which ends with:
TypeError: issubclass() arg 1 must be a class

Is typing supported in dagger function arguments?

#

List[str] as parameter -> compile error

stone dagger
#

i.e:

@object_type
class Test:
    @function
    def container_echo(self, string_arg: list[str]) -> dagger.Container:
        """Returns a container that echoes whatever string argument is provided"""
        return dag.container().from_("alpine:latest").with_exec(string_arg)

and then

 dagger call container-echo --string-arg echo,hello stdout
#

^ that works. Just tested it

delicate whale
#

just for others it seems like dict[str, str] seems to work as well. Just checking

#

yup looks like it works as an argument. Calling it from code worked for me although I have no idea how to pass that dict argument when invoked from the CLI

stone dagger
delicate whale
#

fair enough

#

in case anyone needs this sort of functionality, JSON seems to deserialise OK using the python JSON lib