From 56338fa314d2c5bceb8b1756a50ed64ea8984abe Mon Sep 17 00:00:00 2001 From: LevonW-IIS <103007146+LevonW-IIS@users.noreply.github.com> Date: Wed, 23 Apr 2025 10:23:00 +1200 Subject: [PATCH 1/3] fix typing of add_chart --- src/pptx/shapes/shapetree.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pptx/shapes/shapetree.py b/src/pptx/shapes/shapetree.py index 29623f1f..3e6fc51b 100644 --- a/src/pptx/shapes/shapetree.py +++ b/src/pptx/shapes/shapetree.py @@ -36,7 +36,6 @@ from pptx.util import Emu, lazyproperty if TYPE_CHECKING: - from pptx.chart.chart import Chart from pptx.chart.data import ChartData from pptx.enum.chart import XL_CHART_TYPE from pptx.enum.shapes import MSO_CONNECTOR_TYPE, MSO_SHAPE @@ -241,7 +240,7 @@ def add_chart( cx: Length, cy: Length, chart_data: ChartData, - ) -> Chart: + ) -> GraphicFrame: """Add a new chart of `chart_type` to the slide. The chart is positioned at (`x`, `y`), has size (`cx`, `cy`), and depicts `chart_data`. @@ -255,7 +254,7 @@ def add_chart( rId = self.part.add_chart_part(chart_type, chart_data) graphicFrame = self._add_chart_graphicFrame(rId, x, y, cx, cy) self._recalculate_extents() - return cast("Chart", self._shape_factory(graphicFrame)) + return cast(GraphicFrame, self._shape_factory(graphicFrame)) def add_connector( self, @@ -287,7 +286,8 @@ def add_group_shape(self, shapes: Iterable[BaseShape] = ()) -> GroupShape: grpSp = self._element.add_grpSp() for shape in shapes: grpSp.insert_element_before( - shape._element, "p:extLst" # pyright: ignore[reportPrivateUsage] + shape._element, + "p:extLst", # pyright: ignore[reportPrivateUsage] ) if shapes: grpSp.recalculate_extents() From 8b4ed17aa8b65ba7dc9dad14ce5305684f8b9466 Mon Sep 17 00:00:00 2001 From: LevonW-IIS <103007146+LevonW-IIS@users.noreply.github.com> Date: Wed, 23 Apr 2025 10:31:02 +1200 Subject: [PATCH 2/3] fix formatting --- src/pptx/shapes/shapetree.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pptx/shapes/shapetree.py b/src/pptx/shapes/shapetree.py index 3e6fc51b..bb5baad0 100644 --- a/src/pptx/shapes/shapetree.py +++ b/src/pptx/shapes/shapetree.py @@ -286,8 +286,7 @@ def add_group_shape(self, shapes: Iterable[BaseShape] = ()) -> GroupShape: grpSp = self._element.add_grpSp() for shape in shapes: grpSp.insert_element_before( - shape._element, - "p:extLst", # pyright: ignore[reportPrivateUsage] + shape._element, "p:extLst", # pyright: ignore[reportPrivateUsage] ) if shapes: grpSp.recalculate_extents() From 822792567d16e25c1c3712802f6e84f949a23ee6 Mon Sep 17 00:00:00 2001 From: LevonW-IIS <103007146+LevonW-IIS@users.noreply.github.com> Date: Wed, 23 Apr 2025 10:31:35 +1200 Subject: [PATCH 3/3] fix formatting --- src/pptx/shapes/shapetree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pptx/shapes/shapetree.py b/src/pptx/shapes/shapetree.py index bb5baad0..c3f78bed 100644 --- a/src/pptx/shapes/shapetree.py +++ b/src/pptx/shapes/shapetree.py @@ -286,7 +286,7 @@ def add_group_shape(self, shapes: Iterable[BaseShape] = ()) -> GroupShape: grpSp = self._element.add_grpSp() for shape in shapes: grpSp.insert_element_before( - shape._element, "p:extLst", # pyright: ignore[reportPrivateUsage] + shape._element, "p:extLst" # pyright: ignore[reportPrivateUsage] ) if shapes: grpSp.recalculate_extents()