Update border_radius parameter type to float#492
Update border_radius parameter type to float#492HU-Bro wants to merge 1 commit intopresenton:mainfrom
Conversation
Change border_radius type from int to float for better precision. This is part of fixing powerpoint export errors, together with `PptxAutoShapeBoxModel` `border_radius: Optional[int] = None` → `Optional[float]` PptxPictureBoxModel `border_radius: Optional[List[int]] = None` → `Optional[List[float]]` https://github.com/presenton/presenton/tree/main/electron/servers/fastapi/services/pptx_presentation_creator.py `apply_border_radius_to_shape(self, shape, border_radius: Optional[int])` → `Optional[float]` https://github.com/presenton/presenton/tree/main/electron/servers/fastapi/utils/image_utils.py `round_image_corners(image, radii: List[int])` → `List[float]`
There was a problem hiding this comment.
Pull request overview
This PR aims to improve border radius precision for PowerPoint shape rendering by changing the border_radius type used when applying corner rounding to PPTX shapes.
Changes:
- Updated
apply_border_radius_to_shape(...)to acceptborder_radius: Optional[float]instead ofOptional[int].
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def apply_border_radius_to_shape(self, shape: Shape, border_radius: Optional[float]): | ||
| if not border_radius: | ||
| return |
There was a problem hiding this comment.
The method annotation was updated to Optional[float], but the source model still defines border_radius as Optional[int] and actively rounds floats to ints via validators (see electron/servers/fastapi/models/pptx_models.py around lines 131–142). As a result, float precision likely won’t reach this method, and the change doesn’t fully match the PR description (also applies to PptxPictureBoxModel.border_radius, which is still List[int]). Consider updating the Pydantic models/validators (and any image rounding helpers) to accept/store floats end-to-end, or revert this signature change if rounding-to-int is intentional.
Change border_radius type from int to float for better precision. This is part of fixing powerpoint export errors, together with
PptxAutoShapeBoxModelborder_radius: Optional[int] = None→Optional[float]PptxPictureBoxModel
border_radius: Optional[List[int]] = None→Optional[List[float]]https://github.com/presenton/presenton/tree/main/electron/servers/fastapi/services/pptx_presentation_creator.py
apply_border_radius_to_shape(self, shape, border_radius: Optional[int])→Optional[float]https://github.com/presenton/presenton/tree/main/electron/servers/fastapi/utils/image_utils.py
round_image_corners(image, radii: List[int])→List[float]