Skip to content

Commit b004bf2

Browse files
committed
fix(test): cast shapes in PPTX parser test for correct type handling
- Updated the test script to cast shapes to the correct type before accessing text frames, ensuring proper functionality of the PPTX parser during testing.
1 parent 27a641f commit b004bf2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/document-search/test_pptx_parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import asyncio
77
import os
88
from pathlib import Path
9+
from typing import cast
910

1011
from pptx import Presentation
1112
from pptx.util import Inches
13+
from pptx.shapes.autoshape import Shape
1214

1315
from ragbits.core.sources.local import LocalFileSource
1416
from ragbits.document_search.documents.document import Document, DocumentMeta, DocumentType
@@ -27,7 +29,8 @@ async def create_dummy_pptx(file_path: str):
2729
if title and title.has_text_frame:
2830
title.text_frame.text = "Test Presentation"
2931
if subtitle and subtitle.has_text_frame:
30-
subtitle.text_frame.text = "A presentation for testing the PPTX parser."
32+
shape = cast(Shape, subtitle)
33+
shape.text_frame.text = "A presentation for testing the PPTX parser."
3134

3235
# Slide 2: Text, Shape, and Hyperlink
3336
bullet_slide_layout = prs.slide_layouts[1]
@@ -39,7 +42,7 @@ async def create_dummy_pptx(file_path: str):
3942

4043
body_shape = shapes.placeholders[1]
4144
if body_shape and body_shape.has_text_frame:
42-
tf = body_shape.text_frame
45+
tf = cast(Shape, body_shape).text_frame
4346
tf.text = "This is a bullet point."
4447

4548
p = tf.add_paragraph()

0 commit comments

Comments
 (0)