Skip to content

Commit 5b81981

Browse files
IgorTavcarclaude
andcommitted
Add PIL Image import for type hints under TYPE_CHECKING
Resolves the Image.Image forward reference in load_pdf's return type without adding PIL as a runtime import. Based on: Layout-Parser#174 (kairi003) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 23b2ec8 commit 5b81981

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/layoutparser/io/pdf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
# limitations under the License.
1414

1515
from io import BytesIO
16-
from typing import BinaryIO, List, Union, Optional, Dict, Tuple
16+
from typing import BinaryIO, List, Union, Optional, Dict, Tuple, TYPE_CHECKING
1717

1818
import pdfplumber
1919
import pandas as pd
2020

21+
if TYPE_CHECKING:
22+
from PIL import Image
23+
2124
from ..elements import Layout
2225
from .basic import load_dataframe
2326

0 commit comments

Comments
 (0)