From 3cac7655d4b09717c1fddfe4ee7d535d2a5decdb Mon Sep 17 00:00:00 2001 From: yazawazi <47273265+Yazawazi@users.noreply.github.com> Date: Wed, 28 Feb 2024 17:11:27 +0800 Subject: [PATCH] fix: `IPython.display` check --- backend/funix/decorator/magic.py | 61 +++++++++++++++++++------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/backend/funix/decorator/magic.py b/backend/funix/decorator/magic.py index b0b0811..c51bbb2 100644 --- a/backend/funix/decorator/magic.py +++ b/backend/funix/decorator/magic.py @@ -494,32 +494,45 @@ def anal_function_result( if single_return_type in supported_basic_file_types: if isinstance(call_result[position], list): - call_result[position] = [ - handle_ipython_audio_image_video(single) - if isinstance( - single, - ( - __ipython_display.Audio, - __ipython_display.Video, - __ipython_display.Image, - ), - ) - else get_static_uri(single) - for single in call_result[position] - ] + if __ipython_use: + call_result[position] = [ + handle_ipython_audio_image_video(single) + if isinstance( + single, + ( + __ipython_display.Audio, + __ipython_display.Video, + __ipython_display.Image, + ), + ) + else get_static_uri(single) + for single in call_result[position] + ] + else: + call_result[position] = [ + get_static_uri(single) + for single in call_result[position] + ] else: - call_result[position] = ( - handle_ipython_audio_image_video(call_result[position]) - if isinstance( - call_result[position], - ( - __ipython_display.Audio, - __ipython_display.Video, - __ipython_display.Image, - ), + if __ipython_use: + call_result[position] = ( + handle_ipython_audio_image_video( + call_result[position] + ) + if isinstance( + call_result[position], + ( + __ipython_display.Audio, + __ipython_display.Video, + __ipython_display.Image, + ), + ) + else get_static_uri(call_result[position]) + ) + else: + call_result[position] = get_static_uri( + call_result[position] ) - else get_static_uri(call_result[position]) - ) return call_result else: if return_type_parsed == "Figure":