Skip to content

Commit fb3cbdd

Browse files
authored
fix: move IPython import (#304)
* fix: move IPython import * fix the mock
1 parent 6c0bdef commit fb3cbdd

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

haystack_experimental/dataclasses/image_content.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from haystack.components.fetchers.link_content import LinkContentFetcher
1414
from haystack.lazy_imports import LazyImport
1515
from haystack.utils import is_in_jupyter
16-
from IPython.display import display
1716

1817
from haystack_experimental.components.image_converters.image_utils import MIME_TO_FORMAT
1918

@@ -85,6 +84,8 @@ def show(self) -> None:
8584
image = Image.open(image_bytes)
8685

8786
if is_in_jupyter():
87+
# ipython is not a core dependency so we cannot import it at the module level
88+
from IPython.display import display
8889
display(image)
8990
else:
9091
image.show()

test/dataclasses/test_image_content.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_image_content_show_in_jupyter(test_files_path):
4242
)
4343

4444
with patch("haystack_experimental.dataclasses.image_content.is_in_jupyter", return_value=True), \
45-
patch("haystack_experimental.dataclasses.image_content.display") as mock_display:
45+
patch("IPython.display.display") as mock_display:
4646
image_content.show()
4747

4848
mock_display.assert_called_once()

0 commit comments

Comments
 (0)