Skip to content

Commit

Permalink
Support Deferred Type Annotations in Dataset Previews (#1798)
Browse files Browse the repository at this point in the history
* use include for previewType

Signed-off-by: Sajid Alam <[email protected]>

* update flowchart to accept name or annotation for preview type

Signed-off-by: Sajid Alam <[email protected]>

* revert FE changes

Signed-off-by: Sajid Alam <[email protected]>

---------

Signed-off-by: Sajid Alam <[email protected]>
  • Loading branch information
SajidAlamQB authored Mar 12, 2024
1 parent 1ff461d commit 7cf36bd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion package/kedro_viz/models/flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,15 @@ def set_preview_type(cls, _):
return None

try:
return inspect.signature(cls.dataset.preview).return_annotation.__name__
preview_type_annotation = inspect.signature(
cls.dataset.preview
).return_annotation
# Attempt to get the name attribute, if it exists.
# Otherwise, use str to handle the annotation directly.
preview_type_name = getattr(
preview_type_annotation, "__name__", str(preview_type_annotation)
)
return preview_type_name

except Exception as exc: # pylint: disable=broad-except # pragma: no cover
logger.warning(
Expand Down

0 comments on commit 7cf36bd

Please sign in to comment.