From 7cf36bdcfe308bcb258db8dfe23bc5a349c789b1 Mon Sep 17 00:00:00 2001 From: Sajid Alam <90610031+SajidAlamQB@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:08:53 +0000 Subject: [PATCH] Support Deferred Type Annotations in Dataset Previews (#1798) * use include for previewType Signed-off-by: Sajid Alam * update flowchart to accept name or annotation for preview type Signed-off-by: Sajid Alam * revert FE changes Signed-off-by: Sajid Alam --------- Signed-off-by: Sajid Alam --- package/kedro_viz/models/flowchart.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/package/kedro_viz/models/flowchart.py b/package/kedro_viz/models/flowchart.py index c7e0b4aed7..5f8230c75b 100644 --- a/package/kedro_viz/models/flowchart.py +++ b/package/kedro_viz/models/flowchart.py @@ -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(