Skip to content

Comments

refactor(chart-render): use typed pptx access wrappers for chart ops#37

Merged
tmustier merged 2 commits intomainfrom
refactor/chart-render-pptx-access-pass2
Feb 12, 2026
Merged

refactor(chart-render): use typed pptx access wrappers for chart ops#37
tmustier merged 2 commits intomainfrom
refactor/chart-render-pptx-access-pass2

Conversation

@tmustier
Copy link
Owner

Summary

Continue the dynamic-access cleanup by moving remaining chart-render runtime probes into pptx_access helpers and updating chart_render.py to consume those typed wrappers.

Changes

Shared helper expansions (clean_slides/pptx_access.py)

Added wrappers for chart-render paths that previously relied on Any and direct dynamic attribute chains:

  • chart XML and chart insertion
    • chart_xml_element(...)
    • slide_add_chart(...)
  • chart/plot mutation
    • set_chart_has_legend(...)
    • chart_series(...)
    • chart_plots(...)
    • chart_first_plot(...)
    • set_plot_has_data_labels(...)
    • plot_data_labels(...)
  • series/point styling helpers
    • series_points(...)
    • point_fill_solid(...)
    • point_fill_fore_color(...)
    • point_line_fill_background(...)
  • slide/page helpers
    • slide_size_emu(...)
  • text helpers
    • paragraph_font(...)
    • set_font_size(...)

chart_render.py migration

  • Removed Any-based chart handling in this module for chart insertion/mutation paths.
  • Replaced:
    • cast(Any, slide.shapes).add_chart(...) with slide_add_chart(...)
    • chart_frame.chart access with shape_chart(...)
    • chart.has_legend = ... with set_chart_has_legend(...)
    • chart.plots[0] + direct data-label access with chart_first_plot(...), set_plot_has_data_labels(...), plot_data_labels(...)
    • direct _element access with chart_xml_element(...) in label/title XML edits
    • direct point formatting chains with point helpers
    • slide.part.package...presentation... chain with slide_size_emu(...)
    • paragraph font getattr(...) access with paragraph_font(...) + set_font_size(...)
  • Added local XML protocols for minimal typed OOXML traversal (_XmlElementLike, _XmlSettable).

Tests

  • Expanded tests/test_pptx_access.py with dedicated coverage for all newly introduced chart mutation/slide access helpers:
    • adding chart through slide helper
    • chart legend mutation
    • chart xml extraction
    • plot/data-label mutation
    • series/point helper behavior
    • slide size extraction
    • paragraph font size mutation

Validation

  • .venv/bin/ruff check clean_slides tests
  • .venv/bin/pyright
  • .venv/bin/pytest -q
  • .venv/bin/pre-commit run --all-files

All green locally.

@tmustier tmustier merged commit cb41664 into main Feb 12, 2026
7 checks passed
@tmustier tmustier deleted the refactor/chart-render-pptx-access-pass2 branch February 12, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant