Closed KGB33 closed 6 days ago
As a workaround, I can annotate the constructor instead:
from typing import Annotated, Any
import dagger
from dagger import dag, function, object_type, DefaultPath, Ignore
@object_type
class DaggerUnhashableTypeList:
directory_arg: dagger.Directory
def __init__(
self,
directory_arg: Annotated[dagger.Directory, DefaultPath("/"), Ignore([".venv"])],
) -> None:
self.directory_arg = directory_arg
@function
async def grep_dir(
self,
pattern: str,
) -> str:
"""Returns lines that match a pattern in the files of the provided Directory"""
return await (
dag.container()
.from_("alpine:latest")
.with_mounted_directory("/mnt", self.directory_arg)
.with_workdir("/mnt")
.with_exec(["grep", "-R", pattern, "."])
.stdout()
)
What is the issue?
When using the new
dagger.Ignore
annotation on object fields, I get aTypeError: unhashable type: 'list'
error.Dagger version
dagger v0.12.6 (registry.dagger.io/engine:v0.12.6) linux/amd64
Steps to reproduce
Using the below module, run
dagger functions
.Log output
Logs
``` Error: input: module.withSource.initialize resolve: failed to initialize module: failed to call module "dagger-unhashable-type-list" to get functions: call constructor: process "/runtime" did not complete successfully: exit code: 1 Stderr: ╭───────────────────── Traceback (most recent call last) ──────────────────────╮ │ /runtime:8 in