Yo - I have defined a custom `DagsterType` and an...
# ask-community
g
Yo - I have defined a custom
DagsterType
and annotated the function return value for my
@asset
definition. In the UI, the asset is being shown to return
Any
, not my custom type. Type definition
Copy code
GeoJSONFeatureCollection = DagsterType(
    name="GeoJSONFeatureCollection",
    type_check_fn=is_geojson_feature_collection,
    typing_type=Dict[str, Any],
)
Asset definition (abridged):
Copy code
@asset(
    ...
)
def nifc_active_fire_perimeters_geojson(
    context: OpExecutionContext,
) -> GeoJSONFeatureCollection:
    ...
If I explicitly specify
dagster_type=GeoJSONFeatureCollection
, then the UI shows the correct type. I was expecting that the type inference code would be able to figure this out for me. Did I miss something?
c
Hm the type inference code should be able to figure this out… Flagging to the team
Ah I think I see what’s going on here - check out https://docs.dagster.io/concepts/types#using-dagster-types-with-pep-484-type-annotations Essentially
GeoJSONFeatureCollection
isn’t a valid annotation since it’s a variable, what you want to do is provide
GeoJSONFeatureCollection
as the
dagster_type
explicitly, then use the inner type
Dict[str, Any]
as the annotation
👍 1
g
Thank you. Looks like I just didn't understand the docs, and maybe also not Python 😁
c
Anyone who says they understand python is lying
😁 1