https://dagster.io/ logo
#ask-community
Title
# ask-community
m

moritz

02/20/2023, 8:29 PM
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

Rasmus Bonnevie

02/21/2023, 9:36 AM
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

moritz

02/21/2023, 9:38 AM
As far as I understand, any Python type should be accepted, too. But maybe only basic types?
r

Rasmus Bonnevie

02/21/2023, 9:38 AM
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

moritz

02/21/2023, 9:40 AM
I tried that already, no luck 😕
For now I've removed all type annotations which makes it work but is annoying, of course.
r

Rasmus Bonnevie

02/21/2023, 9:42 AM
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

moritz

02/21/2023, 9:43 AM
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

Rasmus Bonnevie

02/21/2023, 9:44 AM
and wrapping everything in custom Dagster types doesn't resolve it either?
m

moritz

02/21/2023, 9:44 AM
I haven't tried that yet.
r

Rasmus Bonnevie

02/21/2023, 9:47 AM
hope you find a solution!
m

moritz

02/21/2023, 9:49 AM
Thanks 🙂
c

claire

02/21/2023, 11:02 PM
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

Ismael Rodrigues

02/23/2023, 11:45 PM
Just use "list" instead and will do it
no capital first char, just list
3 Views