Skip to content

Commit 023ba11

Browse files
committed
Fix PIL dependencies
1 parent d104ee7 commit 023ba11

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

libs/community/tests/integration_tests/document_loaders/parsers/test_pdf_parsers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
import re
44
from pathlib import Path
5-
from typing import Iterator
5+
from typing import TYPE_CHECKING, Iterator
66

77
import pytest
8-
from PIL.Image import Image
98

109
import langchain_community.document_loaders.parsers as pdf_parsers
1110
from langchain_community.document_loaders.base import BaseBlobParser
@@ -18,6 +17,10 @@
1817
PyPDFParser,
1918
)
2019

20+
if TYPE_CHECKING:
21+
from PIL.Image import Image
22+
23+
2124
# PDFs to test parsers on.
2225
HELLO_PDF = Path(__file__).parent.parent.parent / "examples" / "hello.pdf"
2326

@@ -135,7 +138,7 @@ def test_extract_images_text_from_pdf_pypdfium2parser() -> None:
135138

136139

137140
class EmptyImageBlobParser(BaseImageBlobParser):
138-
def _analyze_image(self, img: Image) -> str:
141+
def _analyze_image(self, img: "Image") -> str:
139142
return "Hello world"
140143

141144

@@ -157,6 +160,7 @@ def _analyze_image(self, img: Image) -> str:
157160
("PyMuPDFParser", {}),
158161
],
159162
)
163+
@pytest.mark.requires("pillow")
160164
def test_mode_and_extract_images_variations(
161165
parser_factory: str,
162166
params: dict,

0 commit comments

Comments
 (0)