I'm having some trouble with generics: ``` Error:...
# hamilton-help
i
I'm having some trouble with generics:
Copy code
Error: Type requirement mismatch. Expected enrichments:typing.Sequence[type[data_loader.BaseEnrichment]] got ():<class 'tuple'> instead.
  Error: Type requirement mismatch. Expected preferred_src:typing.Literal['csv', 'prq'] got csv:<class 'str'> instead.
As you can see, the inputs are valid, but they're not being accepted. Any idea what can be done about that, other than making the type hints more "dumb"?
s
It could be a bug in Hamilton’s type checking code? https://github.com/DAGWorks-Inc/hamilton/blob/main/hamilton/htypes.py#L39
should be easy to reproduce and fix — at least for that last one.
let me know if I have accurately gotten the test case right
i
I don't believe a set is considered a Sequence. I think it's an Iterable, but not sequence. Btw, do you know if Iterable works as a type hint?
Other than that, the test case does seem to reflect my use case
s
Ah good point on iterable.
Fixed i think.. (code is ugly … but contained)
i
Nice! Re Sequence - I don't know if it's a real use case, but
range
objects may also be accepted there
s
I think that should work (confirmed with test case). Can get this out this week.
👍 1