Skip to content

Commit 4afeb05

Browse files
committed
refactor: remove hardcoded dimensions in simple_example.py and update PictureProps to use TypedDict for better type safety
1 parent 251c6ca commit 4afeb05

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

examples/simple_example.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ def main():
6363
EXAMPLE_DIR / "images" / "python-logo.png",
6464
left=(50, "pt"),
6565
top=(100, "pt"),
66-
width=(300, "pt"),
67-
height=(80, "pt"),
6866
)
6967
.text(
7068
"The Python logo",

src/tppt/pptx/shape/picture.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
from typing import IO, Literal, NotRequired, assert_never
1+
from typing import IO, Literal, NotRequired, TypedDict, assert_never
22

33
from pptx.opc.constants import CONTENT_TYPE
44
from pptx.shapes.picture import Movie as PptxMovie
55
from pptx.shapes.picture import Picture as PptxPicture
66

7-
from tppt.types import FilePath
7+
from tppt.types import FilePath, Length, LiteralLength
88

99
from . import BaseShape, RangeProps
1010

1111

12-
class PictureProps(RangeProps):
12+
class PictureProps(TypedDict):
1313
"""Picture properties."""
1414

15+
left: Length | LiteralLength
16+
top: Length | LiteralLength
17+
width: NotRequired[Length | LiteralLength]
18+
height: NotRequired[Length | LiteralLength]
19+
1520

1621
class PictureData(PictureProps):
1722
"""Picture data."""

0 commit comments

Comments
 (0)