I have defined a `NamedTuple` class called `Table...
# ask-community
m
I have defined a
NamedTuple
class called
TableInfo
and created an asset that should return a list of them.
Copy code
@asset
def tables() -> list[TableInfo]:
I get the following error:
Copy code
dagster._core.errors.DagsterInvalidDefinitionError: Invalid type: dagster_type must be an instance of DagsterType or a Python type: got list[TableInfo].
I don't see why it shouldn't work. Is this a known limitation or am I doing something wrong?
r
since the asset function is kind of a meta definition that gets transformed into a proper
AssetsDefinition
instance, I think the type hints are parsed programmatically to link into Dagster's typing and validation functionality (https://docs.dagster.io/concepts/types). So it only accepts Dagster types, which is also what the message is saying. I believe you can make custom ones, but I honestly haven't really made use of it yet.
m
As far as I understand, any Python type should be accepted, too. But maybe only basic types?
r
yeah, was just browsing the docs and I agree that appears to be the case, that it should wrap anything else automatically
ah wait, try and use `List`from
typing
maybe?
m
I tried that already, no luck 😕
For now I've removed all type annotations which makes it work but is annoying, of course.
r
hm, maybe it wraps the list type automatically, but then forgets to do it in a nested sense - so if you make a custom type for
TableInfo
it might help? Just guessing at this point 😀
m
I also tried an
op
with a single return value and that caused the error, too. So I don't think that's it.
Thank you for your help. I guess, I will open an issue for this.
r
and wrapping everything in custom Dagster types doesn't resolve it either?
m
I haven't tried that yet.
r
hope you find a solution!
m
Thanks 🙂
c
Hi Moritz, what version of dagster are you running? And is it just that code snippet the caused the error? If not, would you mind sharing the full code snippet so I can reproduce?
i
Just use "list" instead and will do it
no capital first char, just list