diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 735edf76a..2492df6d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,6 @@ jobs: run: ruff check src tests - name: ruff format check run: ruff format --check src tests - continue-on-error: true # advisory until format pass is run repo-wide test: name: Test (Python ${{ matrix.python-version }}) diff --git a/src/pptx/chart/xmlwriter.py b/src/pptx/chart/xmlwriter.py index 22616f2ab..5520a2ccb 100644 --- a/src/pptx/chart/xmlwriter.py +++ b/src/pptx/chart/xmlwriter.py @@ -140,7 +140,7 @@ def pt_xml(self, values): in the overall data point sequence of the chart and is started at *offset*. """ - xml = (f' \n') + xml = f' \n' pt_tmpl = ( ' \n' @@ -861,9 +861,7 @@ def _marker_xml(self): no_marker_types = (XL.LINE, XL.LINE_STACKED, XL.LINE_STACKED_100) if self._chart_type in no_marker_types: return ( - " \n" - ' \n' - " \n" + ' \n \n \n' ) return "" @@ -1053,9 +1051,7 @@ def xml(self): def _marker_xml(self): if self._chart_type == XL_CHART_TYPE.RADAR: return ( - " \n" - ' \n' - " \n" + ' \n \n \n' ) return "" @@ -1178,9 +1174,7 @@ def _marker_xml(self): ) if self._chart_type in no_marker_types: return ( - " \n" - ' \n' - " \n" + ' \n \n \n' ) return "" @@ -1552,7 +1546,7 @@ def lvl_pt_xml(level): xml = "" for level in categories.levels: - xml += (" \n" "{lvl_pt_xml}" " \n").format( + xml += (" \n{lvl_pt_xml} \n").format( **{"lvl_pt_xml": lvl_pt_xml(level)} ) return xml @@ -1712,7 +1706,7 @@ def _xVal_tmpl(self): The template for the ```` element for this series, containing the X values and their spreadsheet range reference. """ - return " \n" "{numRef_xml}" " \n" + return " \n{numRef_xml} \n" @property def _yVal_tmpl(self): @@ -1720,7 +1714,7 @@ def _yVal_tmpl(self): The template for the ```` element for this series, containing the Y values and their spreadsheet range reference. """ - return " \n" "{numRef_xml}" " \n" + return " \n{numRef_xml} \n" class _BubbleSeriesXmlWriter(_XySeriesXmlWriter): @@ -1772,7 +1766,7 @@ def _bubbleSize_tmpl(self): containing the bubble size values and their spreadsheet range reference. """ - return " \n" "{numRef_xml}" " \n" + return " \n{numRef_xml} \n" class _BubbleSeriesXmlRewriter(_BaseSeriesXmlRewriter): diff --git a/src/pptx/custom_properties.py b/src/pptx/custom_properties.py index 5ca6fa00e..0c87eb2f5 100644 --- a/src/pptx/custom_properties.py +++ b/src/pptx/custom_properties.py @@ -114,9 +114,7 @@ def set_bool(self, name: str, value: bool) -> None: def set_datetime(self, name: str, value: dt.datetime) -> None: """Write `value` as `` (UTC, ISO-8601).""" if not isinstance(value, dt.datetime): # pyright: ignore[reportUnnecessaryIsInstance] - raise TypeError( - "set_datetime value must be datetime, got %s" % type(value).__name__ - ) + raise TypeError("set_datetime value must be datetime, got %s" % type(value).__name__) self._set_typed(name, value) def _set_typed(self, name: str, value: CustomPropertyValue) -> None: diff --git a/src/pptx/custom_xml.py b/src/pptx/custom_xml.py index 80ecbf8d7..619fd57a9 100644 --- a/src/pptx/custom_xml.py +++ b/src/pptx/custom_xml.py @@ -72,9 +72,7 @@ def __getitem__(self, key): # type: ignore[override] if partname == key or partname.endswith("/" + key): return part raise KeyError("no custom_xml part with partname %r" % key) - raise TypeError( - "custom_xml_parts key must be int or str, got %s" % type(key).__name__ - ) + raise TypeError("custom_xml_parts key must be int or str, got %s" % type(key).__name__) # -- Public lookups ---------------------------------------------------- @@ -127,9 +125,7 @@ def add( `prs.save(...)`. """ if scope not in ("presentation", "package"): - raise ValueError( - "scope must be 'presentation' or 'package', got %r" % (scope,) - ) + raise ValueError("scope must be 'presentation' or 'package', got %r" % (scope,)) package = self._presentation_part.package data_part = CustomXmlPart.new_pair( @@ -182,9 +178,7 @@ def add_string_blob( if not isinstance(content, str): # pyright: ignore[reportUnnecessaryIsInstance] raise TypeError("content must be str, got %s" % type(content).__name__) if encoding not in ("text", "base64"): - raise ValueError( - "encoding must be 'text' or 'base64', got %r" % (encoding,) - ) + raise ValueError("encoding must be 'text' or 'base64', got %r" % (encoding,)) from lxml import etree @@ -288,9 +282,7 @@ def _iter_rel_collections(self): yield self._presentation_part.rels yield self._presentation_part.package._rels - def _resolve( - self, part: Union[CustomXmlPart, int, str] - ) -> CustomXmlPart | None: + def _resolve(self, part: Union[CustomXmlPart, int, str]) -> CustomXmlPart | None: if isinstance(part, CustomXmlPart): return part if isinstance(part, int): @@ -304,8 +296,7 @@ def _resolve( except KeyError: return None raise TypeError( - "remove() argument must be CustomXmlPart, int, or str; got %s" - % type(part).__name__ + "remove() argument must be CustomXmlPart, int, or str; got %s" % type(part).__name__ ) diff --git a/src/pptx/dml/color.py b/src/pptx/dml/color.py index 54155823d..158c5bdc0 100644 --- a/src/pptx/dml/color.py +++ b/src/pptx/dml/color.py @@ -101,8 +101,7 @@ def _validate_brightness_value(self, value): raise ValueError("brightness must be number in range -1.0 to 1.0") if isinstance(self._color, _NoneColor): msg = ( - "can't set brightness when color.type is None. Set color.rgb" - " or .theme_color first." + "can't set brightness when color.type is None. Set color.rgb or .theme_color first." ) raise ValueError(msg) diff --git a/src/pptx/dml/fill.py b/src/pptx/dml/fill.py index 8212af9e8..ee2f9244a 100644 --- a/src/pptx/dml/fill.py +++ b/src/pptx/dml/fill.py @@ -196,7 +196,7 @@ def back_color(self): @property def fore_color(self): """Raise TypeError for types that do not override this property.""" - tmpl = "fill type %s has no foreground color, call .solid() or .pattern" "ed() first" + tmpl = "fill type %s has no foreground color, call .solid() or .patterned() first" raise TypeError(tmpl % self.__class__.__name__) @property diff --git a/src/pptx/dml/line.py b/src/pptx/dml/line.py index 6ee46d76b..119224865 100644 --- a/src/pptx/dml/line.py +++ b/src/pptx/dml/line.py @@ -200,8 +200,11 @@ def join_style(self) -> MSO_LINE_JOIN_STYLE | None: if join is None: return None tag_name = join.tag.split("}")[-1] - return {"round": MSO_LINE_JOIN_STYLE.ROUND, "bevel": MSO_LINE_JOIN_STYLE.BEVEL, - "miter": MSO_LINE_JOIN_STYLE.MITER}[tag_name] + return { + "round": MSO_LINE_JOIN_STYLE.ROUND, + "bevel": MSO_LINE_JOIN_STYLE.BEVEL, + "miter": MSO_LINE_JOIN_STYLE.MITER, + }[tag_name] @join_style.setter def join_style(self, value: MSO_LINE_JOIN_STYLE | None) -> None: diff --git a/src/pptx/enum/text.py b/src/pptx/enum/text.py index 8e13d09a9..88d020dc2 100644 --- a/src/pptx/enum/text.py +++ b/src/pptx/enum/text.py @@ -288,22 +288,14 @@ class PP_AUTO_NUMBER_STYLE(BaseXmlEnum): ALPHA_LC_PERIOD = (8, "alphaLcPeriod", "Lowercase letters with period: a. b. c.") """Lowercase letters with period: a. b. c.""" - ALPHA_UC_PAREN_RIGHT = ( - 9, "alphaUcParenR", "Uppercase letters with parenthesis: A) B) C)" - ) + ALPHA_UC_PAREN_RIGHT = (9, "alphaUcParenR", "Uppercase letters with parenthesis: A) B) C)") """Uppercase letters with parenthesis: A) B) C)""" - ALPHA_LC_PAREN_RIGHT = ( - 10, "alphaLcParenR", "Lowercase letters with parenthesis: a) b) c)" - ) + ALPHA_LC_PAREN_RIGHT = (10, "alphaLcParenR", "Lowercase letters with parenthesis: a) b) c)") """Lowercase letters with parenthesis: a) b) c)""" - ALPHA_UC_PAREN_BOTH = ( - 11, "alphaUcParenBoth", "Uppercase letters in parentheses: (A) (B) (C)" - ) + ALPHA_UC_PAREN_BOTH = (11, "alphaUcParenBoth", "Uppercase letters in parentheses: (A) (B) (C)") """Uppercase letters in parentheses: (A) (B) (C)""" - ALPHA_LC_PAREN_BOTH = ( - 12, "alphaLcParenBoth", "Lowercase letters in parentheses: (a) (b) (c)" - ) + ALPHA_LC_PAREN_BOTH = (12, "alphaLcParenBoth", "Lowercase letters in parentheses: (a) (b) (c)") """Lowercase letters in parentheses: (a) (b) (c)""" diff --git a/src/pptx/opc/constants.py b/src/pptx/opc/constants.py index e1b08a93a..19e0e6bf5 100644 --- a/src/pptx/opc/constants.py +++ b/src/pptx/opc/constants.py @@ -199,8 +199,7 @@ class RELATIONSHIP_TYPE: A_F_CHUNK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" CALC_CHAIN = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain" CERTIFICATE = ( - "http://schemas.openxmlformats.org/package/2006/relationships/digital-signatu" - "re/certificate" + "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/certificate" ) CHART = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" CHARTSHEET = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet" @@ -270,8 +269,7 @@ class RELATIONSHIP_TYPE: ORIGIN = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin" PACKAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package" PIVOT_CACHE_DEFINITION = ( - "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCac" - "heDefinition" + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition" ) PIVOT_CACHE_RECORDS = ( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/spreadsh" @@ -295,8 +293,7 @@ class RELATIONSHIP_TYPE: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata" ) SIGNATURE = ( - "http://schemas.openxmlformats.org/package/2006/relationships/digital-signatu" - "re/signature" + "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature" ) SLIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" SLIDE_LAYOUT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" @@ -321,8 +318,7 @@ class RELATIONSHIP_TYPE: VIEW_PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps" VML_DRAWING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing" VOLATILE_DEPENDENCIES = ( - "http://schemas.openxmlformats.org/officeDocument/2006/relationships/volatile" - "Dependencies" + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/volatileDependencies" ) WEB_SETTINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" WORKSHEET_SOURCE = ( diff --git a/src/pptx/opc/package.py b/src/pptx/opc/package.py index 713759c54..e3a4aae9f 100644 --- a/src/pptx/opc/package.py +++ b/src/pptx/opc/package.py @@ -727,8 +727,7 @@ def target_part(self) -> Part: """|Part| or subtype referred to by this relationship.""" if self.is_external: raise ValueError( - "`.target_part` property on _Relationship is undefined when " - "target-mode is external" + "`.target_part` property on _Relationship is undefined when target-mode is external" ) assert isinstance(self._target, Part) return self._target diff --git a/src/pptx/oxml/chart/shared.py b/src/pptx/oxml/chart/shared.py index 5515aa4be..250f80db8 100644 --- a/src/pptx/oxml/chart/shared.py +++ b/src/pptx/oxml/chart/shared.py @@ -183,9 +183,7 @@ def tx_rich(self): @staticmethod def new_title(): """Return "loose" `c:title` element containing default children.""" - return parse_xml( - "" " " ' ' "" % nsdecls("c") - ) + return parse_xml(' ' % nsdecls("c")) class CT_Tx(BaseOxmlElement): diff --git a/src/pptx/oxml/custom_properties.py b/src/pptx/oxml/custom_properties.py index ba60a6cba..28a6ff402 100644 --- a/src/pptx/oxml/custom_properties.py +++ b/src/pptx/oxml/custom_properties.py @@ -207,9 +207,7 @@ def value_typed(self, value: str) -> None: if not isinstance(value, str): # pyright: ignore[reportUnnecessaryIsInstance] raise TypeError("vt:lpwstr value must be str, got %s" % type(value).__name__) if len(value) > _LPWSTR_MAX_LEN: - raise ValueError( - "vt:lpwstr value exceeds %d-character limit" % _LPWSTR_MAX_LEN - ) + raise ValueError("vt:lpwstr value exceeds %d-character limit" % _LPWSTR_MAX_LEN) self.text = value @@ -292,9 +290,7 @@ def value_typed(self) -> dt.datetime: @value_typed.setter def value_typed(self, value: dt.datetime) -> None: if not isinstance(value, dt.datetime): # pyright: ignore[reportUnnecessaryIsInstance] - raise TypeError( - "vt:filetime value must be datetime, got %s" % type(value).__name__ - ) + raise TypeError("vt:filetime value must be datetime, got %s" % type(value).__name__) # Office writes filetimes as UTC with a literal trailing 'Z'. If the # caller supplied a tz-aware value in another zone, convert; if naive, # assume already UTC (matches CorePropertiesPart's behavior). diff --git a/src/pptx/oxml/custom_xml.py b/src/pptx/oxml/custom_xml.py index f568952bb..f5062bb13 100644 --- a/src/pptx/oxml/custom_xml.py +++ b/src/pptx/oxml/custom_xml.py @@ -32,9 +32,7 @@ class CT_DatastoreItem(BaseOxmlElement): ) schemaRefs = ZeroOrOne("ds:schemaRefs", successors=()) - _datastoreItem_tmpl = ( - '\n' % nsdecls("ds") - ) + _datastoreItem_tmpl = '\n' % nsdecls("ds") @staticmethod def new(itemID: str, schema_refs: Iterable[str] = ()) -> "CT_DatastoreItem": diff --git a/src/pptx/oxml/dml/effect.py b/src/pptx/oxml/dml/effect.py index ee8c5c0c9..252ee55af 100644 --- a/src/pptx/oxml/dml/effect.py +++ b/src/pptx/oxml/dml/effect.py @@ -53,8 +53,16 @@ class CT_EffectList(BaseOxmlElement): _remove_outerShdw: Callable[[], None] _remove_innerShdw: Callable[[], None] - _tag_seq = ("a:blur", "a:fillOverlay", "a:glow", "a:innerShdw", "a:outerShdw", - "a:prstShdw", "a:reflection", "a:softEdge") + _tag_seq = ( + "a:blur", + "a:fillOverlay", + "a:glow", + "a:innerShdw", + "a:outerShdw", + "a:prstShdw", + "a:reflection", + "a:softEdge", + ) innerShdw: CT_InnerShadowEffect | None = ZeroOrOne( # pyright: ignore[reportAssignmentType] "a:innerShdw", successors=_tag_seq[4:] ) diff --git a/src/pptx/oxml/dml/fill.py b/src/pptx/oxml/dml/fill.py index 2ff2255d7..a2e9763ae 100644 --- a/src/pptx/oxml/dml/fill.py +++ b/src/pptx/oxml/dml/fill.py @@ -161,13 +161,13 @@ class CT_PatternFillProperties(BaseOxmlElement): def _new_bgClr(self): """Override default to add minimum subtree.""" - xml = ("\n" ' \n' "\n") % nsdecls("a") + xml = ('\n \n\n') % nsdecls("a") bgClr = parse_xml(xml) return bgClr def _new_fgClr(self): """Override default to add minimum subtree.""" - xml = ("\n" ' \n' "\n") % nsdecls("a") + xml = ('\n \n\n') % nsdecls("a") fgClr = parse_xml(xml) return fgClr diff --git a/src/pptx/oxml/presentation.py b/src/pptx/oxml/presentation.py index 17997c2b1..169852a23 100644 --- a/src/pptx/oxml/presentation.py +++ b/src/pptx/oxml/presentation.py @@ -18,17 +18,15 @@ class CT_Presentation(BaseOxmlElement): get_or_add_sldIdLst: Callable[[], CT_SlideIdList] get_or_add_sldMasterIdLst: Callable[[], CT_SlideMasterIdList] - sldMasterIdLst: CT_SlideMasterIdList | None = ( - ZeroOrOne( # pyright: ignore[reportAssignmentType] - "p:sldMasterIdLst", - successors=( - "p:notesMasterIdLst", - "p:handoutMasterIdLst", - "p:sldIdLst", - "p:sldSz", - "p:notesSz", - ), - ) + sldMasterIdLst: CT_SlideMasterIdList | None = ZeroOrOne( # pyright: ignore[reportAssignmentType] + "p:sldMasterIdLst", + successors=( + "p:notesMasterIdLst", + "p:handoutMasterIdLst", + "p:sldIdLst", + "p:sldSz", + "p:notesSz", + ), ) sldIdLst: CT_SlideIdList | None = ZeroOrOne( # pyright: ignore[reportAssignmentType] "p:sldIdLst", successors=("p:sldSz", "p:notesSz") diff --git a/src/pptx/oxml/simpletypes.py b/src/pptx/oxml/simpletypes.py index 6ceb06f7c..7f65a31a8 100644 --- a/src/pptx/oxml/simpletypes.py +++ b/src/pptx/oxml/simpletypes.py @@ -149,7 +149,7 @@ def convert_to_xml(cls, value): def validate(cls, value): if value not in (True, False): raise TypeError( - "only True or False (and possibly None) may be assigned, got" " '%s'" % value + "only True or False (and possibly None) may be assigned, got '%s'" % value ) @@ -462,7 +462,7 @@ def validate(cls, value): super(ST_LineWidth, cls).validate(value) if value < 0 or value > 20116800: raise ValueError( - "value must be in range 0-20116800 inclusive (0-1584 points)" ", got %d" % value + "value must be in range 0-20116800 inclusive (0-1584 points), got %d" % value ) @@ -605,7 +605,7 @@ def validate(cls, value): cls.validate_int(value) if value < 914400 or value > 51206400: raise ValueError( - "value must be in range(914400, 51206400) (1-56 inches), got" " %d" % value + "value must be in range(914400, 51206400) (1-56 inches), got %d" % value ) diff --git a/src/pptx/oxml/slide.py b/src/pptx/oxml/slide.py index fd039a3fb..87eec7754 100644 --- a/src/pptx/oxml/slide.py +++ b/src/pptx/oxml/slide.py @@ -50,7 +50,7 @@ class CT_Background(BaseOxmlElement): def add_noFill_bgPr(self): """Return a new `p:bgPr` element with noFill properties.""" - xml = "\n" " \n" " \n" "" % nsdecls("a", "p") + xml = "\n \n \n" % nsdecls("a", "p") bgPr = cast(CT_BackgroundProperties, parse_xml(xml)) self._insert_bgPr(bgPr) return bgPr diff --git a/src/pptx/oxml/text.py b/src/pptx/oxml/text.py index 5324f7fe6..adc6ca9fb 100644 --- a/src/pptx/oxml/text.py +++ b/src/pptx/oxml/text.py @@ -177,22 +177,16 @@ def unclear_content(self): @classmethod def _a_txBody_tmpl(cls): - return "\n" " \n" " \n" "\n" % (nsdecls("a")) + return "\n \n \n\n" % (nsdecls("a")) @classmethod def _p_txBody_tmpl(cls): - return ( - "\n" " \n" " \n" "\n" % (nsdecls("p", "a")) - ) + return "\n \n \n\n" % (nsdecls("p", "a")) @classmethod def _txBody_tmpl(cls): - return ( - "\n" - " \n" - " \n" - " \n" - "\n" % (nsdecls("a", "p")) + return "\n \n \n \n\n" % ( + nsdecls("a", "p") ) @@ -405,9 +399,7 @@ class CT_TextParagraph(BaseOxmlElement): ) r = ZeroOrMore("a:r", successors=("a:endParaRPr",)) br = ZeroOrMore("a:br", successors=("a:endParaRPr",)) - endParaRPr: CT_TextCharacterProperties | None = ZeroOrOne( - "a:endParaRPr", successors=() - ) # pyright: ignore[reportAssignmentType] + endParaRPr: CT_TextCharacterProperties | None = ZeroOrOne("a:endParaRPr", successors=()) # pyright: ignore[reportAssignmentType] def add_br(self) -> CT_TextLineBreak: """Return a newly appended `a:br` element.""" @@ -514,9 +506,7 @@ class CT_TextParagraphProperties(BaseOxmlElement): lvl: int = OptionalAttribute( # pyright: ignore[reportAssignmentType] "lvl", ST_TextIndentLevelType, default=0 ) - algn: PP_PARAGRAPH_ALIGNMENT | None = OptionalAttribute( - "algn", PP_PARAGRAPH_ALIGNMENT - ) # pyright: ignore[reportAssignmentType] + algn: PP_PARAGRAPH_ALIGNMENT | None = OptionalAttribute("algn", PP_PARAGRAPH_ALIGNMENT) # pyright: ignore[reportAssignmentType] del _tag_seq @property diff --git a/src/pptx/oxml/xmlchemy.py b/src/pptx/oxml/xmlchemy.py index d5eb62ccc..400b54d8c 100644 --- a/src/pptx/oxml/xmlchemy.py +++ b/src/pptx/oxml/xmlchemy.py @@ -445,7 +445,7 @@ def get_or_change_to_child(obj: BaseOxmlElement): return child get_or_change_to_child.__doc__ = ( - "Return the ``<%s>`` child, replacing any other group element if" " found." + "Return the ``<%s>`` child, replacing any other group element if found." ) % self._nsptagname self._add_to_class(self._get_or_change_to_method_name, get_or_change_to_child) diff --git a/src/pptx/parts/custom_xml.py b/src/pptx/parts/custom_xml.py index 1bf0e42d4..2b1e34189 100644 --- a/src/pptx/parts/custom_xml.py +++ b/src/pptx/parts/custom_xml.py @@ -137,9 +137,7 @@ def props_part(self) -> CustomXmlPropertiesPart: Raises `KeyError` if the props rel is missing — a malformed package the caller is expected to repair via `CustomXmlPart.new_pair(...)`. """ - return cast( - CustomXmlPropertiesPart, self.part_related_by(RT.CUSTOM_XML_PROPS) - ) + return cast(CustomXmlPropertiesPart, self.part_related_by(RT.CUSTOM_XML_PROPS)) @property def datastore_item_id(self) -> str: @@ -201,9 +199,7 @@ def name(self) -> str | None: value = prop.value return value if isinstance(value, str) else None - def add_item( - self, tag: str, text: str = "", **attrs: str - ) -> BaseOxmlElement: + def add_item(self, tag: str, text: str = "", **attrs: str) -> BaseOxmlElement: """Append a child element `text` with `attrs`. Convenience for the common "flat list of items" customXml shape; for @@ -239,8 +235,7 @@ def _parse_payload(xml_payload: XmlPayload) -> BaseOxmlElement: if isinstance(xml_payload, _Element): return cast("BaseOxmlElement", xml_payload) raise TypeError( - "xml_payload must be bytes, str, or lxml _Element; got %s" - % type(xml_payload).__name__ + "xml_payload must be bytes, str, or lxml _Element; got %s" % type(xml_payload).__name__ ) diff --git a/src/pptx/shapes/shapetree.py b/src/pptx/shapes/shapetree.py index 42c32de83..553382b62 100644 --- a/src/pptx/shapes/shapetree.py +++ b/src/pptx/shapes/shapetree.py @@ -287,7 +287,8 @@ def add_group_shape(self, shapes: Iterable[BaseShape] = ()) -> GroupShape: grpSp = self._element.add_grpSp() for shape in shapes: grpSp.insert_element_before( - shape._element, "p:extLst" # pyright: ignore[reportPrivateUsage] + shape._element, + "p:extLst", # pyright: ignore[reportPrivateUsage] ) if shapes: grpSp.recalculate_extents() diff --git a/src/pptx/table.py b/src/pptx/table.py index b0a2241f9..df3637a3f 100644 --- a/src/pptx/table.py +++ b/src/pptx/table.py @@ -391,7 +391,7 @@ def split(self) -> None: `.is_merge_origin` before calling. """ if not self.is_merge_origin: - raise ValueError("not a merge-origin cell; only a merge-origin cell can be sp" "lit") + raise ValueError("not a merge-origin cell; only a merge-origin cell can be split") tc_range = TcRange.from_merge_origin(self._tc) diff --git a/tests/chart/test_axis.py b/tests/chart/test_axis.py index 9dbb50f51..cebdca360 100644 --- a/tests/chart/test_axis.py +++ b/tests/chart/test_axis.py @@ -736,17 +736,17 @@ def has_tf_get_fixture(self, request): ( "c:title{a:b=c}", True, - "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr" ")", + "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr)", ), ( "c:title{a:b=c}/c:tx", True, - "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr" ")", + "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr)", ), ( "c:title{a:b=c}/c:tx/c:strRef", True, - "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr" ")", + "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr)", ), ("c:title/c:tx/c:rich", True, "c:title/c:tx/c:rich"), ("c:title", False, "c:title"), diff --git a/tests/chart/test_chart.py b/tests/chart/test_chart.py index 667253347..5f5d37868 100644 --- a/tests/chart/test_chart.py +++ b/tests/chart/test_chart.py @@ -171,7 +171,7 @@ def cat_ax_raise_fixture(self): params=[ ( "c:chartSpace{a:b=c}", - "c:chartSpace{a:b=c}/c:txPr/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr" ")", + "c:chartSpace{a:b=c}/c:txPr/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr)", ), ("c:chartSpace/c:txPr/a:p", "c:chartSpace/c:txPr/a:p/a:pPr/a:defRPr"), ( @@ -486,17 +486,17 @@ def has_tf_get_fixture(self, request): ( "c:title{a:b=c}", True, - "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr" ")", + "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr)", ), ( "c:title{a:b=c}/c:tx", True, - "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr" ")", + "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr)", ), ( "c:title{a:b=c}/c:tx/c:strRef", True, - "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr" ")", + "c:title{a:b=c}/c:tx/c:rich/(a:bodyPr,a:lstStyle,a:p/a:pPr/a:defRPr)", ), ("c:title/c:tx/c:rich", True, "c:title/c:tx/c:rich"), ("c:title", False, "c:title"), diff --git a/tests/chart/test_datalabel.py b/tests/chart/test_datalabel.py index ad02efc10..3dfe3c5cc 100644 --- a/tests/chart/test_datalabel.py +++ b/tests/chart/test_datalabel.py @@ -66,8 +66,7 @@ def it_gets_or_adds_rich_element_to_help(self, rich_fixture): ), ( "c:ser{a:b=c}/c:dLbls/c:dLbl/(c:idx{val=9},c:txPr/(a:bodyPr,a:p))", - "c:ser{a:b=c}/c:dLbls/c:dLbl/(c:idx{val=9},c:txPr/(a:bodyPr,a:p/a:p" - "Pr/a:defRPr))", + "c:ser{a:b=c}/c:dLbls/c:dLbl/(c:idx{val=9},c:txPr/(a:bodyPr,a:p/a:pPr/a:defRPr))", ), ] ) diff --git a/tests/chart/test_legend.py b/tests/chart/test_legend.py index d77cd9f37..77d39717e 100644 --- a/tests/chart/test_legend.py +++ b/tests/chart/test_legend.py @@ -72,7 +72,7 @@ def font_fixture(self, request): ("c:legend/c:layout/c:manualLayout/c:xMode{val=factor}", 0.0), ("c:legend/c:layout/c:manualLayout/(c:xMode,c:x{val=0.42})", 0.42), ( - "c:legend/c:layout/c:manualLayout/(c:xMode{val=factor},c:x{val=0.42" "})", + "c:legend/c:layout/c:manualLayout/(c:xMode{val=factor},c:x{val=0.42})", 0.42, ), ] diff --git a/tests/chart/test_plot.py b/tests/chart/test_plot.py index 7e0f75e2d..d28584d8c 100644 --- a/tests/chart/test_plot.py +++ b/tests/chart/test_plot.py @@ -420,24 +420,23 @@ def it_can_determine_the_chart_type_of_a_plot(self, chart_type_fixture): ("c:lineChart/c:grouping{val=percentStacked}", XL.LINE_MARKERS_STACKED_100), ("c:lineChart/c:ser/c:marker/c:symbol{val=none}", XL.LINE), ( - "c:lineChart/(c:grouping{val=stacked},c:ser/c:marker/c:symbol{val=n" "one})", + "c:lineChart/(c:grouping{val=stacked},c:ser/c:marker/c:symbol{val=none})", XL.LINE_STACKED, ), ( - "c:lineChart/(c:grouping{val=percentStacked},c:ser/c:marker/c:symbo" "l{val=none})", + "c:lineChart/(c:grouping{val=percentStacked},c:ser/c:marker/c:symbol{val=none})", XL.LINE_STACKED_100, ), ("c:pieChart", XL.PIE), ("c:pieChart/c:ser/c:explosion{val=25}", XL.PIE_EXPLODED), ("c:scatterChart/c:scatterStyle", XL.XY_SCATTER), ( - "c:scatterChart/(c:scatterStyle{val=lineMarker},c:ser/c:spPr/a:ln/a" ":noFill)", + "c:scatterChart/(c:scatterStyle{val=lineMarker},c:ser/c:spPr/a:ln/a:noFill)", XL.XY_SCATTER, ), ("c:scatterChart/c:scatterStyle{val=lineMarker}", XL.XY_SCATTER_LINES), ( - "c:scatterChart/(c:scatterStyle{val=lineMarker},c:ser/c:marker/c:sy" - "mbol{val=none})", + "c:scatterChart/(c:scatterStyle{val=lineMarker},c:ser/c:marker/c:symbol{val=none})", XL.XY_SCATTER_LINES_NO_MARKERS, ), ( @@ -460,7 +459,7 @@ def it_can_determine_the_chart_type_of_a_plot(self, chart_type_fixture): ("c:radarChart/c:radarStyle{val=marker}", XL.RADAR_MARKERS), ("c:radarChart/c:radarStyle{val=filled}", XL.RADAR_FILLED), ( - "c:radarChart/(c:radarStyle{val=marker},c:ser/c:marker/c:symbol{val" "=none})", + "c:radarChart/(c:radarStyle{val=marker},c:ser/c:marker/c:symbol{val=none})", XL.RADAR, ), ] diff --git a/tests/chart/test_series.py b/tests/chart/test_series.py index 9a60351e1..f26157126 100644 --- a/tests/chart/test_series.py +++ b/tests/chart/test_series.py @@ -144,7 +144,7 @@ def subclass_fixture(self): ("c:ser/c:val/c:numRef/c:numCache", ()), ("c:ser/c:val/c:numRef/c:numCache/c:ptCount{val=0}", ()), ( - 'c:ser/c:val/c:numRef/c:numCache/(c:ptCount{val=1},c:pt{idx=0}/c:v"' '1.1")', + 'c:ser/c:val/c:numRef/c:numCache/(c:ptCount{val=1},c:pt{idx=0}/c:v"1.1")', (1.1,), ), ( @@ -153,8 +153,7 @@ def subclass_fixture(self): (1.1, None, 3.3), ), ( - 'c:ser/c:val/c:numLit/(c:ptCount{val=3},c:pt{idx=0}/c:v"1.1",c:pt{i' - 'dx=2}/c:v"3.3")', + 'c:ser/c:val/c:numLit/(c:ptCount{val=3},c:pt{idx=0}/c:v"1.1",c:pt{idx=2}/c:v"3.3")', (1.1, None, 3.3), ), ( @@ -420,7 +419,7 @@ def subclass_fixture(self): ("c:ser/c:yVal/c:numRef", ()), ("c:ser/c:val/c:numRef/c:numCache", ()), ( - "c:ser/c:yVal/c:numRef/c:numCache/(c:ptCount{val=1},c:pt{idx=0}/c:v" '"1.1")', + 'c:ser/c:yVal/c:numRef/c:numCache/(c:ptCount{val=1},c:pt{idx=0}/c:v"1.1")', (1.1,), ), ( @@ -469,7 +468,7 @@ def it_supports_len(self, len_fixture): params=[ ("c:barChart/c:ser/c:order{val=42}", 0, 0), ( - "c:barChart/(c:ser/c:order{val=9},c:ser/c:order{val=6},c:ser/c:orde" "r{val=3})", + "c:barChart/(c:ser/c:order{val=9},c:ser/c:order{val=6},c:ser/c:order{val=3})", 2, 0, ), @@ -494,7 +493,7 @@ def getitem_fixture(self, request, _SeriesFactory_, series_): ("c:barChart", 0), ("c:barChart/c:ser/c:order{val=4}", 1), ( - "c:barChart/(c:ser/c:order{val=4},c:ser/c:order{val=1},c:ser/c:orde" "r{val=6})", + "c:barChart/(c:ser/c:order{val=4},c:ser/c:order{val=1},c:ser/c:order{val=6})", 3, ), ("c:plotArea/c:barChart", 0), diff --git a/tests/chart/test_xmlwriter.py b/tests/chart/test_xmlwriter.py index 7db641719..daa683ed9 100644 --- a/tests/chart/test_xmlwriter.py +++ b/tests/chart/test_xmlwriter.py @@ -514,8 +514,7 @@ def clone_fixture(self, request): def replace_fixture(self, request, chart_data_, _adjust_ser_count_, _rewrite_ser_data_): rewriter = _BaseSeriesXmlRewriter(chart_data_) chartSpace = element( - "c:chartSpace/c:chart/c:plotArea/c:barChart/(c:ser/c:order{val=0" - "},c:ser/c:order{val=1})" + "c:chartSpace/c:chart/c:plotArea/c:barChart/(c:ser/c:order{val=0},c:ser/c:order{val=1})" ) plotArea = chartSpace.xpath("c:chart/c:plotArea")[0] sers = chartSpace.xpath(".//c:ser") diff --git a/tests/dml/test_line.py b/tests/dml/test_line.py index b55852b18..b1bcb7b41 100644 --- a/tests/dml/test_line.py +++ b/tests/dml/test_line.py @@ -189,9 +189,7 @@ def it_can_change_its_end_arrowhead_length( ("p:spPr/a:ln{cap=flat}", MSO_LINE_CAP_STYLE.FLAT), ], ) - def it_knows_its_cap_style( - self, spPr_cxml: str, expected_value: MSO_LINE_CAP_STYLE | None - ): + def it_knows_its_cap_style(self, spPr_cxml: str, expected_value: MSO_LINE_CAP_STYLE | None): line = LineFormat(element(spPr_cxml)) assert line.cap_style == expected_value @@ -220,9 +218,7 @@ def it_can_change_its_cap_style( ("p:spPr/a:ln/a:miter", MSO_LINE_JOIN_STYLE.MITER), ], ) - def it_knows_its_join_style( - self, spPr_cxml: str, expected_value: MSO_LINE_JOIN_STYLE | None - ): + def it_knows_its_join_style(self, spPr_cxml: str, expected_value: MSO_LINE_JOIN_STYLE | None): line = LineFormat(element(spPr_cxml)) assert line.join_style == expected_value diff --git a/tests/integration/test_customxml_roundtrip.py b/tests/integration/test_customxml_roundtrip.py index ab20e3e35..4d75bf596 100644 --- a/tests/integration/test_customxml_roundtrip.py +++ b/tests/integration/test_customxml_roundtrip.py @@ -123,9 +123,7 @@ def it_round_trips_through_save_load_with_mutations(self): prs = Presentation(_fixture("multipart.pptx")) # mutate something in each layer prs.custom_properties["NewKey"] = "added" - prs.custom_xml_parts.by_name("provenance").add_item( - "added-by-test", "value" - ) + prs.custom_xml_parts.by_name("provenance").add_item("added-by-test", "value") reloaded = _roundtrip(prs) diff --git a/tests/opc/test_package.py b/tests/opc/test_package.py index c0671bc00..0e53a0271 100644 --- a/tests/opc/test_package.py +++ b/tests/opc/test_package.py @@ -599,7 +599,7 @@ def it_raises_KeyError_on_partname_not_found(self, content_type_map): with pytest.raises(KeyError) as e: content_type_map[PackURI("/!blat/rhumba.1x&")] assert str(e.value) == ( - "\"no content-type for partname '/!blat/rhumba.1x&' " 'in [Content_Types].xml"' + "\"no content-type for partname '/!blat/rhumba.1x&' in [Content_Types].xml\"" ) def it_raises_TypeError_on_key_not_instance_of_PackURI(self, content_type_map): @@ -984,7 +984,7 @@ def but_it_raises_ValueError_on_target_part_for_external_rel(self): with pytest.raises(ValueError) as e: relationship.target_part assert str(e.value) == ( - "`.target_part` property on _Relationship is undefined when " "target-mode is external" + "`.target_part` property on _Relationship is undefined when target-mode is external" ) def it_knows_its_target_partname(self, part_): @@ -1000,8 +1000,7 @@ def but_it_raises_ValueError_on_target_partname_for_external_rel(self): relationship.target_partname assert str(e.value) == ( - "`.target_partname` property on _Relationship is undefined when " - "target-mode is external" + "`.target_partname` property on _Relationship is undefined when target-mode is external" ) def it_knows_the_target_uri_for_an_external_rel(self): diff --git a/tests/oxml/shapes/test_autoshape.py b/tests/oxml/shapes/test_autoshape.py index a03bc7f22..80b352620 100644 --- a/tests/oxml/shapes/test_autoshape.py +++ b/tests/oxml/shapes/test_autoshape.py @@ -254,11 +254,7 @@ def new_ph_sp_fixture(self, request): "\n" % (nsdecls("a", "p"), "%d", "%s", "%s", "%s") ) txBody_snippet = ( - " \n" - " \n" - " \n" - " \n" - " \n" + " \n \n \n \n \n" ) txBody_str = txBody_snippet if id_ in (2, 4, 8) else "" expected_values = (id_, name, expected_attrs, txBody_str) diff --git a/tests/oxml/test_custom_properties.py b/tests/oxml/test_custom_properties.py index c98476a00..7b535825a 100644 --- a/tests/oxml/test_custom_properties.py +++ b/tests/oxml/test_custom_properties.py @@ -29,9 +29,11 @@ def _props_xml(*property_xml_chunks: str) -> bytes: def _property_xml(name: str, pid: int, vt_inner_xml: str) -> str: - return ( - '%s' - % (DEFAULT_FMTID, pid, name, vt_inner_xml) + return '%s' % ( + DEFAULT_FMTID, + pid, + name, + vt_inner_xml, ) @@ -79,7 +81,10 @@ def it_removes_a_property_by_name(self): @pytest.mark.parametrize( ("value", "expected_child_tag"), [ - ("hello", "{http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes}lpwstr"), + ( + "hello", + "{http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes}lpwstr", + ), (42, "{http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes}i4"), (3.14, "{http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes}r8"), (True, "{http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes}bool"), @@ -127,9 +132,7 @@ def it_auto_assigns_unique_pids_starting_at_2(self): def it_skips_used_pids_when_assigning(self): # parse a doc where pid 2 is already used; the next add_property must use 3 - root = parse_xml( - _props_xml(_property_xml("Existing", 2, "x")) - ) + root = parse_xml(_props_xml(_property_xml("Existing", 2, "x"))) new_prop = root.add_property("New", "y") assert new_prop.pid == 3 @@ -152,7 +155,7 @@ def it_round_trips_string_text(self): _property_xml("X", 2, "hello world").encode() if False else ( - "" + '' "hello world" % (nsdecls("op", "vt"), DEFAULT_FMTID) ).encode() @@ -207,9 +210,8 @@ class DescribeCT_VtBool: ) def it_reads_office_and_xsd_boolean_lexical_forms(self, xml_text, expected): prop_xml = ( - "" - "%s" - % (nsdecls("op", "vt"), DEFAULT_FMTID, xml_text) + '' + "%s" % (nsdecls("op", "vt"), DEFAULT_FMTID, xml_text) ) prop = parse_xml(prop_xml.encode()) assert prop.value is expected @@ -221,9 +223,8 @@ def it_writes_office_lexical_form(self, py_value, expected_text): def it_raises_on_invalid_text(self): prop_xml = ( - "" - "maybe" - % (nsdecls("op", "vt"), DEFAULT_FMTID) + '' + "maybe" % (nsdecls("op", "vt"), DEFAULT_FMTID) ) prop = parse_xml(prop_xml.encode()) with pytest.raises(ValueError): @@ -246,7 +247,7 @@ def it_normalizes_a_tz_aware_datetime_to_utc(self): def it_parses_offset_form_too(self): prop_xml = ( - "" + '' "2026-05-05T09:00:00-05:00" % (nsdecls("op", "vt"), DEFAULT_FMTID) ) @@ -263,9 +264,9 @@ def it_replaces_an_existing_value_child(self): def it_returns_None_for_value_when_no_child_present(self): # build a stripped property element by parsing - prop_xml = ( - '' - % (nsdecls("op", "vt"), DEFAULT_FMTID) + prop_xml = '' % ( + nsdecls("op", "vt"), + DEFAULT_FMTID, ) prop = parse_xml(prop_xml.encode()) assert isinstance(prop, CT_Property) diff --git a/tests/oxml/test_simpletypes.py b/tests/oxml/test_simpletypes.py index 261edf550..c047b8849 100644 --- a/tests/oxml/test_simpletypes.py +++ b/tests/oxml/test_simpletypes.py @@ -65,9 +65,7 @@ def it_can_validate_a_value_as_a_python_string(self, valid_str_fixture): # fixtures ------------------------------------------------------- @pytest.fixture - def to_xml_fixture( - self, request, py_value_, str_value_, convert_to_xml_, validate_ - ): + def to_xml_fixture(self, request, py_value_, str_value_, convert_to_xml_, validate_): return ST_SimpleType, py_value_, str_value_ @pytest.fixture( @@ -217,9 +215,7 @@ def it_converts_RGB_string_to_upper_case(self, to_xml_fixture): # fixtures ------------------------------------------------------- - @pytest.fixture( - params=[("deadbf", "DEADBF"), ("012345", "012345"), ("0a1b3c", "0A1B3C")] - ) + @pytest.fixture(params=[("deadbf", "DEADBF"), ("012345", "012345"), ("0a1b3c", "0A1B3C")]) def to_xml_fixture(self, request): value, expected_value = request.param return value, expected_value diff --git a/tests/oxml/test_table.py b/tests/oxml/test_table.py index c64196f9b..ce007e778 100644 --- a/tests/oxml/test_table.py +++ b/tests/oxml/test_table.py @@ -151,7 +151,7 @@ def dimensions_fixture(self, request): ("a:tbl/(a:tr/a:tc,a:tr/a:tc)", [0, 1], []), ("a:tbl/(a:tr/(a:tc,a:tc),a:tr/(a:tc,a:tc))", [2, 1], [1, 3]), ( - "a:tbl/(a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc" ",a:tc))", + "a:tbl/(a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc))", [0, 8], [1, 2, 4, 5, 7, 8], ), @@ -170,7 +170,7 @@ def except_left_fixture(self, request): ("a:tbl/(a:tr/a:tc,a:tr/a:tc)", [0, 1], [1]), ("a:tbl/(a:tr/(a:tc,a:tc),a:tr/(a:tc,a:tc))", [2, 1], [2, 3]), ( - "a:tbl/(a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc" ",a:tc))", + "a:tbl/(a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc))", [0, 8], [3, 4, 5, 6, 7, 8], ), @@ -198,7 +198,7 @@ def in_same_table_fixture(self, request): ("a:tbl/(a:tr/a:tc,a:tr/a:tc)", (0, 1), (0, 1)), ("a:tbl/(a:tr/(a:tc,a:tc),a:tr/(a:tc,a:tc))", (2, 1), (0, 2)), ( - "a:tbl/(a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc" ",a:tc))", + "a:tbl/(a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc))", (4, 8), (4, 7), ), @@ -217,7 +217,7 @@ def left_col_fixture(self, request): ('a:tbl/a:tr/(a:tc/a:txBody/a:p,a:tc/a:txBody/a:p/a:r/a:t"b")', "b"), ('a:tbl/a:tr/(a:tc/a:txBody/a:p/a:r/a:t"a",a:tc/a:txBody/a:p)', "a"), ( - 'a:tbl/a:tr/(a:tc/a:txBody/a:p/a:r/a:t"a",a:tc/a:txBody/a:p/a:r/a:t' '"b")', + 'a:tbl/a:tr/(a:tc/a:txBody/a:p/a:r/a:t"a",a:tc/a:txBody/a:p/a:r/a:t"b")', "a\nb", ), ( @@ -241,7 +241,7 @@ def move_fixture(self, request): ("a:tbl/(a:tr/a:tc,a:tr/a:tc)", (0, 1), (0,)), ("a:tbl/(a:tr/(a:tc,a:tc),a:tr/(a:tc,a:tc))", (2, 1), (0, 1)), ( - "a:tbl/(a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc" ",a:tc))", + "a:tbl/(a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc),a:tr/(a:tc,a:tc,a:tc))", (4, 8), (4, 5), ), diff --git a/tests/parts/test_chart.py b/tests/parts/test_chart.py index 9d9e35903..3893d2543 100644 --- a/tests/parts/test_chart.py +++ b/tests/parts/test_chart.py @@ -93,7 +93,7 @@ def but_it_returns_None_when_the_chart_has_no_xlsx_part(self): [ ( "c:chartSpace{r:a=b}", - "c:chartSpace{r:a=b}/c:externalData{r:id=rId" "42}/c:autoUpdate{val=0}", + "c:chartSpace{r:a=b}/c:externalData{r:id=rId42}/c:autoUpdate{val=0}", ), ( "c:chartSpace/c:externalData{r:id=rId66}", diff --git a/tests/parts/test_custom_properties.py b/tests/parts/test_custom_properties.py index 62d7c76c5..00cfe8903 100644 --- a/tests/parts/test_custom_properties.py +++ b/tests/parts/test_custom_properties.py @@ -20,9 +20,11 @@ def _props_xml(*property_xml_chunks: str) -> bytes: def _property_xml(name: str, pid: int, vt_inner_xml: str) -> str: - return ( - '%s' - % (DEFAULT_FMTID, pid, name, vt_inner_xml) + return '%s' % ( + DEFAULT_FMTID, + pid, + name, + vt_inner_xml, ) @@ -41,7 +43,10 @@ def it_loads_an_existing_part_from_blob(self): _property_xml("Build", 3, "42"), ) part = CustomPropertiesPart.load( - "/docProps/custom.xml", CT.OFC_CUSTOM_PROPERTIES, None, xml # type: ignore[arg-type] + "/docProps/custom.xml", + CT.OFC_CUSTOM_PROPERTIES, + None, + xml, # type: ignore[arg-type] ) assert isinstance(part._element, CT_Properties) assert part.property_names == ("Source", "Build") @@ -94,7 +99,10 @@ def it_round_trips_blob_through_add_and_reparse(self): blob = part.blob # blob is XML that re-parses to an equivalent CustomPropertiesPart reloaded = CustomPropertiesPart.load( - "/docProps/custom.xml", CT.OFC_CUSTOM_PROPERTIES, None, blob # type: ignore[arg-type] + "/docProps/custom.xml", + CT.OFC_CUSTOM_PROPERTIES, + None, + blob, # type: ignore[arg-type] ) assert reloaded.property_names == ("Source", "Build") assert reloaded.get_property("Source").value == "cli" diff --git a/tests/parts/test_custom_xml.py b/tests/parts/test_custom_xml.py index 6d9b58f95..9c3bf9928 100644 --- a/tests/parts/test_custom_xml.py +++ b/tests/parts/test_custom_xml.py @@ -94,14 +94,18 @@ def it_loads_from_blob(self): def it_can_change_the_datastore_item_id(self): part = CustomXmlPropertiesPart.new( - None, PackURI("/customXml/itemProps1.xml"), _GUID_A # type: ignore[arg-type] + None, + PackURI("/customXml/itemProps1.xml"), + _GUID_A, # type: ignore[arg-type] ) part.datastore_item_id = _GUID_B assert part.datastore_item_id == _GUID_B def it_adds_and_removes_schema_refs(self): part = CustomXmlPropertiesPart.new( - None, PackURI("/customXml/itemProps1.xml"), _GUID_A # type: ignore[arg-type] + None, + PackURI("/customXml/itemProps1.xml"), + _GUID_A, # type: ignore[arg-type] ) part.add_schema_ref("urn:a") part.add_schema_ref("urn:b") @@ -145,7 +149,9 @@ def it_auto_generates_a_curly_braced_guid_when_omitted(self): def it_accepts_a_caller_supplied_datastore_item_id(self): pkg = _StubPackage() data = CustomXmlPart.new_pair( - pkg, b"", datastore_item_id=_GUID_A # type: ignore[arg-type] + pkg, + b"", + datastore_item_id=_GUID_A, # type: ignore[arg-type] ) assert data.datastore_item_id == _GUID_A diff --git a/tests/shapes/test_connector.py b/tests/shapes/test_connector.py index f61f0a029..ccb086247 100644 --- a/tests/shapes/test_connector.py +++ b/tests/shapes/test_connector.py @@ -122,8 +122,7 @@ def begin_conn_fixture(self, _connect_begin_to_, _move_begin_to_cxn_): def begin_x_get_fixture(self, request): x, cx, flipH, expected_value = request.param cxnSp = element( - "p:cxnSp/p:spPr/a:xfrm{flipH=%d}/(a:off{x=%d,y=6},a:ext{cx=%d,cy" - "=32})" % (flipH, x, cx) + "p:cxnSp/p:spPr/a:xfrm{flipH=%d}/(a:off{x=%d,y=6},a:ext{cx=%d,cy=32})" % (flipH, x, cx) ) connector = Connector(cxnSp, None) return connector, expected_value @@ -174,8 +173,7 @@ def begin_x_set_fixture(self, request): def begin_y_get_fixture(self, request): y, cy, flipV, expected_value = request.param cxnSp = element( - "p:cxnSp/p:spPr/a:xfrm{flipV=%d}/(a:off{x=6,y=%d},a:ext{cx=32,cy" - "=%d})" % (flipV, y, cy) + "p:cxnSp/p:spPr/a:xfrm{flipV=%d}/(a:off{x=6,y=%d},a:ext{cx=32,cy=%d})" % (flipV, y, cy) ) connector = Connector(cxnSp, None) return connector, expected_value @@ -272,8 +270,7 @@ def end_conn_fixture(self, _connect_end_to_, _move_end_to_cxn_): def end_x_get_fixture(self, request): x, cx, flipH, expected_value = request.param cxnSp = element( - "p:cxnSp/p:spPr/a:xfrm{flipH=%d}/(a:off{x=%d,y=6},a:ext{cx=%d,cy" - "=60})" % (flipH, x, cx) + "p:cxnSp/p:spPr/a:xfrm{flipH=%d}/(a:off{x=%d,y=6},a:ext{cx=%d,cy=60})" % (flipH, x, cx) ) connector = Connector(cxnSp, None) return connector, expected_value @@ -324,8 +321,7 @@ def end_x_set_fixture(self, request): def end_y_get_fixture(self, request): y, cy, flipV, expected_value = request.param cxnSp = element( - "p:cxnSp/p:spPr/a:xfrm{flipV=%d}/(a:off{x=6,y=%d},a:ext{cx=32,cy" - "=%d})" % (flipV, y, cy) + "p:cxnSp/p:spPr/a:xfrm{flipV=%d}/(a:off{x=6,y=%d},a:ext{cx=32,cy=%d})" % (flipV, y, cy) ) connector = Connector(cxnSp, None) return connector, expected_value diff --git a/tests/shapes/test_freeform.py b/tests/shapes/test_freeform.py index dd5f53f0d..f751af198 100644 --- a/tests/shapes/test_freeform.py +++ b/tests/shapes/test_freeform.py @@ -220,7 +220,7 @@ def it_can_start_a_new_path_to_help( _local_to_shape_.assert_called_once_with(builder, start_x, start_y) assert sp.xml == xml( - "p:sp/p:spPr/a:custGeom/a:pathLst/a:path{w=1001,h=2002}/a:moveTo" "/a:pt{x=101,y=202}" + "p:sp/p:spPr/a:custGeom/a:pathLst/a:path{w=1001,h=2002}/a:moveTo/a:pt{x=101,y=202}" ) assert path is sp.xpath(".//a:path")[-1] diff --git a/tests/shapes/test_placeholder.py b/tests/shapes/test_placeholder.py index 94db0fbd7..e00ccc002 100644 --- a/tests/shapes/test_placeholder.py +++ b/tests/shapes/test_placeholder.py @@ -474,7 +474,7 @@ def it_creates_a_pic_element_to_help(self, request, image_size, crop_attr_names) return_value=(42, "bar", image_size), ) picture_ph = PicturePlaceholder( - element("p:sp/(p:nvSpPr/p:cNvPr{id=2,name=foo},p:spPr/a:xfrm/a:ext{cx=99" ",cy=99})"), + element("p:sp/(p:nvSpPr/p:cNvPr{id=2,name=foo},p:spPr/a:xfrm/a:ext{cx=99,cy=99})"), None, ) diff --git a/tests/shapes/test_shapetree.py b/tests/shapes/test_shapetree.py index 80b75723d..7ab92e707 100644 --- a/tests/shapes/test_shapetree.py +++ b/tests/shapes/test_shapetree.py @@ -170,7 +170,7 @@ def clone_ph_fixture(self, placeholder_): "chart,idx=42,orient=vert,sz=half}),p:spPr)" ) placeholder_.element = element( - "p:sp/p:nvSpPr/p:nvPr/p:ph{type=chart,idx=42,orient=vert,sz=half" "}" + "p:sp/p:nvSpPr/p:nvPr/p:ph{type=chart,idx=42,orient=vert,sz=half}" ) return shapes, placeholder_, expected_xml @@ -221,7 +221,7 @@ def len_fixture(self): ("p:spTree/p:nvSpPr/(p:cNvPr{id=foo},p:cNvPr{id=2})", 3), ("p:spTree/p:nvSpPr/(p:cNvPr{id=1fo},p:cNvPr{id=2})", 3), ( - "p:spTree/p:nvSpPr/(p:cNvPr{id=1},p:cNvPr{id=1},p:" "cNvPr{id=1},p:cNvPr{id=4})", + "p:spTree/p:nvSpPr/(p:cNvPr{id=1},p:cNvPr{id=1},p:cNvPr{id=1},p:cNvPr{id=4})", 5, ), ] @@ -246,7 +246,7 @@ def next_id_fixture(self, request): ) def ph_name_fixture(self, request): ph_type, sp_id, orient, expected_name = request.param - spTree = element("p:spTree/(p:cNvPr{name=Title 1},p:cNvPr{name=Table Placeholder " "3})") + spTree = element("p:spTree/(p:cNvPr{name=Title 1},p:cNvPr{name=Table Placeholder 3})") shapes = SlideShapes(spTree, None) return shapes, ph_type, sp_id, orient, expected_name @@ -264,7 +264,7 @@ def turbo_fixture(self, request): ("p:spTree/p:nvSpPr/p:cNvPr{id=2}", True), ("p:spTree/p:nvSpPr/(p:cNvPr{id=1},p:cNvPr{id=3})", False), ( - "p:spTree/p:nvSpPr/(p:cNvPr{id=1},p:cNvPr{id=1},p:" "cNvPr{id=1},p:cNvPr{id=4})", + "p:spTree/p:nvSpPr/(p:cNvPr{id=1},p:cNvPr{id=1},p:cNvPr{id=1},p:cNvPr{id=4})", True, ), ] @@ -1831,7 +1831,15 @@ def it_gets_the_poster_frame_image_from_the_specified_path_to_help( ): BytesIO_ = class_mock(request, "pptx.shapes.shapetree.io.BytesIO") movie_pic_element_creator = _MoviePicElementCreator( - None, None, None, None, None, None, None, "image.png", None # type: ignore + None, + None, + None, + None, + None, + None, + None, + "image.png", + None, # type: ignore ) image_file = movie_pic_element_creator._poster_frame_image_file @@ -1845,7 +1853,15 @@ def but_it_gets_the_poster_frame_image_from_the_default_bytes_when_None_specifie stream_ = instance_mock(request, io.BytesIO) BytesIO_ = class_mock(request, "pptx.shapes.shapetree.io.BytesIO", return_value=stream_) movie_pic_element_creator = _MoviePicElementCreator( - None, None, None, None, None, None, None, None, None # type: ignore + None, + None, + None, + None, + None, + None, + None, + None, + None, # type: ignore ) image_file = movie_pic_element_creator._poster_frame_image_file diff --git a/tests/test_action.py b/tests/test_action.py index dd0193ca6..ba8714b83 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -49,7 +49,7 @@ def it_can_change_its_slide_jump_target( _clear_click_action_.assert_called_once_with(action_setting) part_.relate_to.assert_called_once_with(slide_part_, RT.SLIDE) assert action_setting._element.xml == xml( - "p:cNvPr{a:b=c,r:s=t}/a:hlinkClick{action=ppaction://hlinksldjump,r:id=rI" "d42}", + "p:cNvPr{a:b=c,r:s=t}/a:hlinkClick{action=ppaction://hlinksldjump,r:id=rId42}", ) def but_it_clears_the_target_slide_if_None_is_assigned(self, _clear_click_action_): diff --git a/tests/test_custom_properties.py b/tests/test_custom_properties.py index 64238d1ef..d92a5cb78 100644 --- a/tests/test_custom_properties.py +++ b/tests/test_custom_properties.py @@ -151,9 +151,7 @@ def it_writes_bool_with_set_bool(self, empty_prs): empty_prs.custom_properties.set_bool("X", 0) # type: ignore[arg-type] def it_writes_datetime_with_set_datetime(self, empty_prs): - empty_prs.custom_properties.set_datetime( - "When", dt.datetime(2026, 1, 1, 0, 0, 0) - ) + empty_prs.custom_properties.set_datetime("When", dt.datetime(2026, 1, 1, 0, 0, 0)) assert empty_prs.custom_properties["When"] == dt.datetime(2026, 1, 1, 0, 0, 0) def it_rejects_set_string_with_non_string(self, empty_prs): diff --git a/tests/test_custom_xml.py b/tests/test_custom_xml.py index 6bf4c1d63..4053f8ea4 100644 --- a/tests/test_custom_xml.py +++ b/tests/test_custom_xml.py @@ -107,8 +107,7 @@ def it_finds_by_guid_brace_tolerant(self, empty_prs): assert empty_prs.custom_xml_parts.by_guid(guid) is not None # without braces, lowercase assert ( - empty_prs.custom_xml_parts.by_guid("abcdef12-3456-7890-abcd-ef1234567890") - is not None + empty_prs.custom_xml_parts.by_guid("abcdef12-3456-7890-abcd-ef1234567890") is not None ) def it_returns_None_for_unknown_guid(self, empty_prs): @@ -279,15 +278,15 @@ def it_rejects_non_string_content(self, empty_prs): def it_rejects_unknown_encoding(self, empty_prs): with pytest.raises(ValueError): empty_prs.custom_xml_parts.add_string_blob( - "x", "content", encoding="utf-7" # type: ignore[arg-type] + "x", + "content", + encoding="utf-7", # type: ignore[arg-type] ) def it_supports_package_scope(self, empty_prs): from pptx.opc.constants import RELATIONSHIP_TYPE as RT_ - empty_prs.custom_xml_parts.add_string_blob( - "x", "content", scope="package" - ) + empty_prs.custom_xml_parts.add_string_blob("x", "content", scope="package") rel_types = {r.reltype for r in empty_prs.part.package._rels.values()} assert RT_.CUSTOM_XML in rel_types diff --git a/tests/test_files/customxml/_generate_fixtures.py b/tests/test_files/customxml/_generate_fixtures.py index 86bd30b83..671cd18d1 100644 --- a/tests/test_files/customxml/_generate_fixtures.py +++ b/tests/test_files/customxml/_generate_fixtures.py @@ -39,9 +39,7 @@ def write_presentation_scoped() -> None: def write_package_scoped() -> None: prs = Presentation() prs.custom_xml_parts.add( - b'' - b"" - b"", + b'', name="vsto", scope="package", datastoreItem_id="{ABCDEF12-3456-7890-ABCD-EF1234567890}", diff --git a/tests/text/test_fonts.py b/tests/text/test_fonts.py index 995c78dd2..849421a32 100644 --- a/tests/text/test_fonts.py +++ b/tests/text/test_fonts.py @@ -252,14 +252,7 @@ def iter_fixture(self, _table_count_, stream_read_): font = _Font(stream) _table_count_.return_value = 2 stream_read_.return_value = ( - b"name" - b"xxxx" - b"\x00\x00\x00\x2A" - b"\x00\x00\x00\x15" - b"head" - b"xxxx" - b"\x00\x00\x00\x15" - b"\x00\x00\x00\x2A" + b"namexxxx\x00\x00\x00\x2a\x00\x00\x00\x15headxxxx\x00\x00\x00\x15\x00\x00\x00\x2a" ) expected_values = [("name", 42, 21), ("head", 21, 42)] return font, expected_values @@ -384,7 +377,7 @@ def read_fixture(self, file_): def read_flds_fixture(self, file_): stream = _Stream(file_) tmpl, offset = b">4sHH", 0 - file_.read.return_value = b"foob" b"\x00\x2A" b"\x00\x15" + file_.read.return_value = b"foob\x00\x2a\x00\x15" expected_values = (b"foob", 42, 21) return stream, tmpl, offset, file_, expected_values @@ -458,7 +451,7 @@ def italic_fixture(self, request, _macStyle_): @pytest.fixture def macStyle_fixture(self): - bytes_ = b"xxxxyyyy....................................\xF0\xBA........" + bytes_ = b"xxxxyyyy....................................\xf0\xba........" stream = _Stream(io.BytesIO(bytes_)) offset, length = 0, len(bytes_) head_table = _HeadTable(None, stream, offset, length) @@ -602,7 +595,7 @@ def bytes_fixture(self, stream_): @pytest.fixture( params=[ - (1, 0, b"Foob\x8Ar", "Foobär"), + (1, 0, b"Foob\x8ar", "Foobär"), (1, 1, b"Foobar", None), (0, 9, "Foobär".encode("utf-16-be"), "Foobär"), (3, 6, "Foobär".encode("utf-16-be"), "Foobär"), @@ -631,23 +624,14 @@ def family_fixture(self, request, _names_prop_): @pytest.fixture def header_fixture(self, _table_bytes_prop_): name_table = _NameTable(None, None, None, None) - _table_bytes_prop_.return_value = b"\x00\x00\x00\x02\x00\x2A" + _table_bytes_prop_.return_value = b"\x00\x00\x00\x02\x00\x2a" expected_value = (0, 2, 42) return name_table, expected_value @pytest.fixture def name_hdr_fixture(self): name_table = _NameTable(None, None, None, None) - bufr = ( - b"123456" - b"123456789012" - b"\x00\x00" - b"\x00\x01" - b"\x00\x02" - b"\x00\x03" - b"\x00\x04" - b"\x00\x05" - ) + bufr = b"123456123456789012\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05" idx = 1 expected_value = (0, 1, 2, 3, 4, 5) return name_table, bufr, idx, expected_value