Skip to content

Commit 278b47b

Browse files
committed
fix(enum): replace read-only enum values
Some enum values like `MSO_SHAPE_TYPE.MIXED` are never produced by `python-pptx` and so were removed during the enum modernization in commit `01b86e64`. However, in at least one downstream system these values are referenced even though they can never actually occur. Replace these "read-only" values to avoid downstream breakage.
1 parent 0f980cd commit 278b47b

File tree

7 files changed

+56
-13
lines changed

7 files changed

+56
-13
lines changed

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Release History
44
---------------
55

6+
1.0.2 (2024-08-07)
7+
++++++++++++++++++
8+
9+
- fix: #1003 restore read-only enum members
10+
611
1.0.1 (2024-08-05)
712
++++++++++++++++++
813

src/pptx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
if TYPE_CHECKING:
2626
from pptx.opc.package import Part
2727

28-
__version__ = "1.0.1"
28+
__version__ = "1.0.2"
2929

3030
sys.modules["pptx.exceptions"] = exceptions
3131
del sys

src/pptx/enum/chart.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ class XL_DATA_LABEL_POSITION(BaseXmlEnum):
335335
LEFT = (-4131, "l", "The data label is positioned to the left of the data point.")
336336
"""The data label is positioned to the left of the data point."""
337337

338+
MIXED = (6, "", "Data labels are in multiple positions (read-only).")
339+
"""Data labels are in multiple positions (read-only)."""
340+
338341
OUTSIDE_END = (
339342
2,
340343
"outEnd",
@@ -370,8 +373,8 @@ class XL_LEGEND_POSITION(BaseXmlEnum):
370373
CORNER = (2, "tr", "In the upper-right corner of the chart border.")
371374
"""In the upper-right corner of the chart border."""
372375

373-
CUSTOM = (-4161, "", "A custom position.")
374-
"""A custom position."""
376+
CUSTOM = (-4161, "", "A custom position (read-only).")
377+
"""A custom position (read-only)."""
375378

376379
LEFT = (-4131, "l", "Left of the chart.")
377380
"""Left of the chart."""

src/pptx/enum/dml.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ class MSO_PATTERN_TYPE(BaseXmlEnum):
319319
ZIG_ZAG = (38, "zigZag", "Zig Zag")
320320
"""Zig Zag"""
321321

322-
MIXED = (-2, "", "Mixed pattern")
323-
"""Mixed pattern"""
322+
MIXED = (-2, "", "Mixed pattern (read-only).")
323+
"""Mixed pattern (read-only)."""
324324

325325

326326
MSO_PATTERN = MSO_PATTERN_TYPE
@@ -394,8 +394,12 @@ class MSO_THEME_COLOR_INDEX(BaseXmlEnum):
394394
TEXT_2 = (15, "tx2", "Specifies the Text 2 theme color.")
395395
"""Specifies the Text 2 theme color."""
396396

397-
MIXED = (-2, "", "Indicates multiple theme colors are used, such as in a group shape.")
398-
"""Indicates multiple theme colors are used, such as in a group shape."""
397+
MIXED = (
398+
-2,
399+
"",
400+
"Indicates multiple theme colors are used, such as in a group shape (read-only).",
401+
)
402+
"""Indicates multiple theme colors are used, such as in a group shape (read-only)."""
399403

400404

401405
MSO_THEME_COLOR = MSO_THEME_COLOR_INDEX

src/pptx/enum/lang.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,3 +680,6 @@ class MSO_LANGUAGE_ID(BaseXmlEnum):
680680

681681
ZULU = (1077, "zu-ZA", "The Zulu language.")
682682
"""The Zulu language."""
683+
684+
MIXED = (-2, "", "More than one language in specified range (read-only).")
685+
"""More than one language in specified range (read-only)."""

src/pptx/enum/shapes.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,9 @@ class MSO_CONNECTOR_TYPE(BaseXmlEnum):
748748
STRAIGHT = (1, "line", "Straight line connector.")
749749
"""Straight line connector."""
750750

751+
MIXED = (-2, "", "Return value only; indicates a combination of other states.")
752+
"""Return value only; indicates a combination of other states."""
753+
751754

752755
MSO_CONNECTOR = MSO_CONNECTOR_TYPE
753756

@@ -843,6 +846,9 @@ class MSO_SHAPE_TYPE(BaseEnum):
843846
WEB_VIDEO = (26, "Web video")
844847
"""Web video"""
845848

849+
MIXED = (-2, "Multiple shape types (read-only).")
850+
"""Multiple shape types (read-only)."""
851+
846852

847853
MSO = MSO_SHAPE_TYPE
848854

@@ -871,6 +877,16 @@ class PP_MEDIA_TYPE(BaseEnum):
871877
SOUND = (1, "Audio media such as MP3.")
872878
"""Audio media such as MP3."""
873879

880+
MIXED = (
881+
-2,
882+
"Return value only; indicates multiple media types, typically for a collection of shapes."
883+
" May not be applicable in python-pptx.",
884+
)
885+
"""Return value only; indicates multiple media types.
886+
887+
Typically for a collection of shapes. May not be applicable in python-pptx.
888+
"""
889+
874890

875891
class PP_PLACEHOLDER_TYPE(BaseXmlEnum):
876892
"""Specifies one of the 18 distinct types of placeholder.
@@ -937,14 +953,14 @@ class PP_PLACEHOLDER_TYPE(BaseXmlEnum):
937953
TITLE = (1, "title", "Title")
938954
"""Title"""
939955

940-
VERTICAL_BODY = (6, "", "Vertical Body")
941-
"""Vertical Body"""
956+
VERTICAL_BODY = (6, "", "Vertical Body (read-only).")
957+
"""Vertical Body (read-only)."""
942958

943-
VERTICAL_OBJECT = (17, "", "Vertical Object")
944-
"""Vertical Object"""
959+
VERTICAL_OBJECT = (17, "", "Vertical Object (read-only).")
960+
"""Vertical Object (read-only)."""
945961

946-
VERTICAL_TITLE = (5, "", "Vertical Title")
947-
"""Vertical Title"""
962+
VERTICAL_TITLE = (5, "", "Vertical Title (read-only).")
963+
"""Vertical Title (read-only)."""
948964

949965
MIXED = (-2, "", "Return value only; multiple placeholders of differing types.")
950966
"""Return value only; multiple placeholders of differing types."""

src/pptx/enum/text.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class MSO_AUTO_SIZE(BaseEnum):
5757
)
5858
"""The font size is reduced as necessary to fit the text within the shape."""
5959

60+
MIXED = (-2, "Return value only; indicates a combination of automatic sizing schemes are used.")
61+
"""Return value only; indicates a combination of automatic sizing schemes are used."""
62+
6063

6164
class MSO_TEXT_UNDERLINE_TYPE(BaseXmlEnum):
6265
"""
@@ -134,6 +137,9 @@ class MSO_TEXT_UNDERLINE_TYPE(BaseXmlEnum):
134137
WORDS = (1, "words", "Specifies underlining words.")
135138
"""Specifies underlining words."""
136139

140+
MIXED = (-2, "", "Specifies a mix of underline types (read-only).")
141+
"""Specifies a mix of underline types (read-only)."""
142+
137143

138144
MSO_UNDERLINE = MSO_TEXT_UNDERLINE_TYPE
139145

@@ -161,6 +167,9 @@ class MSO_VERTICAL_ANCHOR(BaseXmlEnum):
161167
BOTTOM = (4, "b", "Aligns text to bottom of text frame")
162168
"""Aligns text to bottom of text frame"""
163169

170+
MIXED = (-2, "", "Return value only; indicates a combination of the other states.")
171+
"""Return value only; indicates a combination of the other states."""
172+
164173

165174
MSO_ANCHOR = MSO_VERTICAL_ANCHOR
166175

@@ -214,5 +223,8 @@ class PP_PARAGRAPH_ALIGNMENT(BaseXmlEnum):
214223
THAI_DISTRIBUTE = (6, "thaiDist", "Thai distributed")
215224
"""Thai distributed"""
216225

226+
MIXED = (-2, "", "Multiple alignments are present in a set of paragraphs (read-only).")
227+
"""Multiple alignments are present in a set of paragraphs (read-only)."""
228+
217229

218230
PP_ALIGN = PP_PARAGRAPH_ALIGNMENT

0 commit comments

Comments
 (0)