Skip to content

Commit a4ed261

Browse files
committed
refactor: simplify type annotations in formatted_text functions and enhance module docstring
1 parent 92dd8f6 commit a4ed261

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

examples/formatted_text.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
from pathlib import Path
44

55
import tppt
6-
import tppt.pptx.shape.text
76

87
EXAMPLE_DIR = Path(__file__).parent
98

109

1110
def main():
12-
def formatted_text(text: tppt.pptx.shape.text.Text, /) -> tppt.pptx.shape.text.Text:
11+
def formatted_text(text: tppt.pptx.Text, /) -> tppt.pptx.Text:
1312
run = text.text_frame.add_paragraph().add_run()
1413
run.text = "Hello, world!"
1514
font = run.font
@@ -19,14 +18,14 @@ def formatted_text(text: tppt.pptx.shape.text.Text, /) -> tppt.pptx.shape.text.T
1918
return text
2019

2120
def functional_text(
22-
text_obj: tppt.pptx.shape.text.Text,
21+
text_obj: tppt.pptx.Text,
2322
/,
2423
*,
2524
text: str,
2625
bold: bool = False,
2726
italic: bool = False,
2827
color: tppt.types.Color | tppt.types.LiteralColor | None = None,
29-
) -> tppt.pptx.shape.text.Text:
28+
) -> tppt.pptx.Text:
3029
run = text_obj.text_frame.add_paragraph().add_run()
3130
run.text = text
3231
font = run.font

src/tppt/__init__.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
"""Typed Python PowerPoint Tool"""
1+
"""🐍 🛡️ Typed Python PowerPoint Tool 🛡️ 🐍"""
22

33
import importlib.metadata
44
from typing import Callable, Concatenate, ParamSpec, TypeVar
55

6-
from tppt.pptx import Presentation as Presentation
7-
from tppt.template.slide_layout import Placeholder as Placeholder
8-
from tppt.template.slide_layout import SlideLayout as SlideLayout
9-
from tppt.template.slide_master import Layout as Layout
10-
from tppt.template.slide_master import SlideMaster as SlideMaster
11-
from tppt.template.slide_master import slide_master as slide_master
12-
136
from . import pptx as pptx
147
from . import types as types
8+
from .pptx import Presentation as Presentation
9+
from .template.slide_layout import Placeholder as Placeholder
10+
from .template.slide_layout import SlideLayout as SlideLayout
11+
from .template.slide_master import Layout as Layout
12+
from .template.slide_master import SlideMaster as SlideMaster
13+
from .template.slide_master import slide_master as slide_master
1514

1615
__version__ = importlib.metadata.version("tppt")
1716

0 commit comments

Comments
 (0)