Skip to content

Commit 0097f57

Browse files
authored
Merge pull request #10 from MHoroszowski/feature/ruff-format-pass
style: ruff format pass over src and tests (no semantic changes)
2 parents f8c67e7 + e791d0b commit 0097f57

49 files changed

Lines changed: 190 additions & 248 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
run: ruff check src tests
3636
- name: ruff format check
3737
run: ruff format --check src tests
38-
continue-on-error: true # advisory until format pass is run repo-wide
3938

4039
test:
4140
name: Test (Python ${{ matrix.python-version }})

src/pptx/chart/xmlwriter.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def pt_xml(self, values):
140140
in the overall data point sequence of the chart and is started at
141141
*offset*.
142142
"""
143-
xml = (f' <c:ptCount val="{len(values)}"/>\n')
143+
xml = f' <c:ptCount val="{len(values)}"/>\n'
144144

145145
pt_tmpl = (
146146
' <c:pt idx="{idx}">\n'
@@ -861,9 +861,7 @@ def _marker_xml(self):
861861
no_marker_types = (XL.LINE, XL.LINE_STACKED, XL.LINE_STACKED_100)
862862
if self._chart_type in no_marker_types:
863863
return (
864-
" <c:marker>\n"
865-
' <c:symbol val="none"/>\n'
866-
" </c:marker>\n"
864+
' <c:marker>\n <c:symbol val="none"/>\n </c:marker>\n'
867865
)
868866
return ""
869867

@@ -1053,9 +1051,7 @@ def xml(self):
10531051
def _marker_xml(self):
10541052
if self._chart_type == XL_CHART_TYPE.RADAR:
10551053
return (
1056-
" <c:marker>\n"
1057-
' <c:symbol val="none"/>\n'
1058-
" </c:marker>\n"
1054+
' <c:marker>\n <c:symbol val="none"/>\n </c:marker>\n'
10591055
)
10601056
return ""
10611057

@@ -1178,9 +1174,7 @@ def _marker_xml(self):
11781174
)
11791175
if self._chart_type in no_marker_types:
11801176
return (
1181-
" <c:marker>\n"
1182-
' <c:symbol val="none"/>\n'
1183-
" </c:marker>\n"
1177+
' <c:marker>\n <c:symbol val="none"/>\n </c:marker>\n'
11841178
)
11851179
return ""
11861180

@@ -1552,7 +1546,7 @@ def lvl_pt_xml(level):
15521546

15531547
xml = ""
15541548
for level in categories.levels:
1555-
xml += (" <c:lvl>\n" "{lvl_pt_xml}" " </c:lvl>\n").format(
1549+
xml += (" <c:lvl>\n{lvl_pt_xml} </c:lvl>\n").format(
15561550
**{"lvl_pt_xml": lvl_pt_xml(level)}
15571551
)
15581552
return xml
@@ -1712,15 +1706,15 @@ def _xVal_tmpl(self):
17121706
The template for the ``<c:xVal>`` element for this series, containing
17131707
the X values and their spreadsheet range reference.
17141708
"""
1715-
return " <c:xVal{nsdecls}>\n" "{numRef_xml}" " </c:xVal>\n"
1709+
return " <c:xVal{nsdecls}>\n{numRef_xml} </c:xVal>\n"
17161710

17171711
@property
17181712
def _yVal_tmpl(self):
17191713
"""
17201714
The template for the ``<c:yVal>`` element for this series, containing
17211715
the Y values and their spreadsheet range reference.
17221716
"""
1723-
return " <c:yVal{nsdecls}>\n" "{numRef_xml}" " </c:yVal>\n"
1717+
return " <c:yVal{nsdecls}>\n{numRef_xml} </c:yVal>\n"
17241718

17251719

17261720
class _BubbleSeriesXmlWriter(_XySeriesXmlWriter):
@@ -1772,7 +1766,7 @@ def _bubbleSize_tmpl(self):
17721766
containing the bubble size values and their spreadsheet range
17731767
reference.
17741768
"""
1775-
return " <c:bubbleSize{nsdecls}>\n" "{numRef_xml}" " </c:bubbleSize>\n"
1769+
return " <c:bubbleSize{nsdecls}>\n{numRef_xml} </c:bubbleSize>\n"
17761770

17771771

17781772
class _BubbleSeriesXmlRewriter(_BaseSeriesXmlRewriter):

src/pptx/custom_properties.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ def set_bool(self, name: str, value: bool) -> None:
114114
def set_datetime(self, name: str, value: dt.datetime) -> None:
115115
"""Write `value` as `<vt:filetime>` (UTC, ISO-8601)."""
116116
if not isinstance(value, dt.datetime): # pyright: ignore[reportUnnecessaryIsInstance]
117-
raise TypeError(
118-
"set_datetime value must be datetime, got %s" % type(value).__name__
119-
)
117+
raise TypeError("set_datetime value must be datetime, got %s" % type(value).__name__)
120118
self._set_typed(name, value)
121119

122120
def _set_typed(self, name: str, value: CustomPropertyValue) -> None:

src/pptx/custom_xml.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ def __getitem__(self, key): # type: ignore[override]
7272
if partname == key or partname.endswith("/" + key):
7373
return part
7474
raise KeyError("no custom_xml part with partname %r" % key)
75-
raise TypeError(
76-
"custom_xml_parts key must be int or str, got %s" % type(key).__name__
77-
)
75+
raise TypeError("custom_xml_parts key must be int or str, got %s" % type(key).__name__)
7876

7977
# -- Public lookups ----------------------------------------------------
8078

@@ -127,9 +125,7 @@ def add(
127125
`prs.save(...)`.
128126
"""
129127
if scope not in ("presentation", "package"):
130-
raise ValueError(
131-
"scope must be 'presentation' or 'package', got %r" % (scope,)
132-
)
128+
raise ValueError("scope must be 'presentation' or 'package', got %r" % (scope,))
133129

134130
package = self._presentation_part.package
135131
data_part = CustomXmlPart.new_pair(
@@ -182,9 +178,7 @@ def add_string_blob(
182178
if not isinstance(content, str): # pyright: ignore[reportUnnecessaryIsInstance]
183179
raise TypeError("content must be str, got %s" % type(content).__name__)
184180
if encoding not in ("text", "base64"):
185-
raise ValueError(
186-
"encoding must be 'text' or 'base64', got %r" % (encoding,)
187-
)
181+
raise ValueError("encoding must be 'text' or 'base64', got %r" % (encoding,))
188182

189183
from lxml import etree
190184

@@ -288,9 +282,7 @@ def _iter_rel_collections(self):
288282
yield self._presentation_part.rels
289283
yield self._presentation_part.package._rels
290284

291-
def _resolve(
292-
self, part: Union[CustomXmlPart, int, str]
293-
) -> CustomXmlPart | None:
285+
def _resolve(self, part: Union[CustomXmlPart, int, str]) -> CustomXmlPart | None:
294286
if isinstance(part, CustomXmlPart):
295287
return part
296288
if isinstance(part, int):
@@ -304,8 +296,7 @@ def _resolve(
304296
except KeyError:
305297
return None
306298
raise TypeError(
307-
"remove() argument must be CustomXmlPart, int, or str; got %s"
308-
% type(part).__name__
299+
"remove() argument must be CustomXmlPart, int, or str; got %s" % type(part).__name__
309300
)
310301

311302

src/pptx/dml/color.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ def _validate_brightness_value(self, value):
101101
raise ValueError("brightness must be number in range -1.0 to 1.0")
102102
if isinstance(self._color, _NoneColor):
103103
msg = (
104-
"can't set brightness when color.type is None. Set color.rgb"
105-
" or .theme_color first."
104+
"can't set brightness when color.type is None. Set color.rgb or .theme_color first."
106105
)
107106
raise ValueError(msg)
108107

src/pptx/dml/fill.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def back_color(self):
196196
@property
197197
def fore_color(self):
198198
"""Raise TypeError for types that do not override this property."""
199-
tmpl = "fill type %s has no foreground color, call .solid() or .pattern" "ed() first"
199+
tmpl = "fill type %s has no foreground color, call .solid() or .patterned() first"
200200
raise TypeError(tmpl % self.__class__.__name__)
201201

202202
@property

src/pptx/dml/line.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,11 @@ def join_style(self) -> MSO_LINE_JOIN_STYLE | None:
200200
if join is None:
201201
return None
202202
tag_name = join.tag.split("}")[-1]
203-
return {"round": MSO_LINE_JOIN_STYLE.ROUND, "bevel": MSO_LINE_JOIN_STYLE.BEVEL,
204-
"miter": MSO_LINE_JOIN_STYLE.MITER}[tag_name]
203+
return {
204+
"round": MSO_LINE_JOIN_STYLE.ROUND,
205+
"bevel": MSO_LINE_JOIN_STYLE.BEVEL,
206+
"miter": MSO_LINE_JOIN_STYLE.MITER,
207+
}[tag_name]
205208

206209
@join_style.setter
207210
def join_style(self, value: MSO_LINE_JOIN_STYLE | None) -> None:

src/pptx/enum/text.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,22 +288,14 @@ class PP_AUTO_NUMBER_STYLE(BaseXmlEnum):
288288
ALPHA_LC_PERIOD = (8, "alphaLcPeriod", "Lowercase letters with period: a. b. c.")
289289
"""Lowercase letters with period: a. b. c."""
290290

291-
ALPHA_UC_PAREN_RIGHT = (
292-
9, "alphaUcParenR", "Uppercase letters with parenthesis: A) B) C)"
293-
)
291+
ALPHA_UC_PAREN_RIGHT = (9, "alphaUcParenR", "Uppercase letters with parenthesis: A) B) C)")
294292
"""Uppercase letters with parenthesis: A) B) C)"""
295293

296-
ALPHA_LC_PAREN_RIGHT = (
297-
10, "alphaLcParenR", "Lowercase letters with parenthesis: a) b) c)"
298-
)
294+
ALPHA_LC_PAREN_RIGHT = (10, "alphaLcParenR", "Lowercase letters with parenthesis: a) b) c)")
299295
"""Lowercase letters with parenthesis: a) b) c)"""
300296

301-
ALPHA_UC_PAREN_BOTH = (
302-
11, "alphaUcParenBoth", "Uppercase letters in parentheses: (A) (B) (C)"
303-
)
297+
ALPHA_UC_PAREN_BOTH = (11, "alphaUcParenBoth", "Uppercase letters in parentheses: (A) (B) (C)")
304298
"""Uppercase letters in parentheses: (A) (B) (C)"""
305299

306-
ALPHA_LC_PAREN_BOTH = (
307-
12, "alphaLcParenBoth", "Lowercase letters in parentheses: (a) (b) (c)"
308-
)
300+
ALPHA_LC_PAREN_BOTH = (12, "alphaLcParenBoth", "Lowercase letters in parentheses: (a) (b) (c)")
309301
"""Lowercase letters in parentheses: (a) (b) (c)"""

src/pptx/opc/constants.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ class RELATIONSHIP_TYPE:
199199
A_F_CHUNK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk"
200200
CALC_CHAIN = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain"
201201
CERTIFICATE = (
202-
"http://schemas.openxmlformats.org/package/2006/relationships/digital-signatu"
203-
"re/certificate"
202+
"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/certificate"
204203
)
205204
CHART = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"
206205
CHARTSHEET = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet"
@@ -270,8 +269,7 @@ class RELATIONSHIP_TYPE:
270269
ORIGIN = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin"
271270
PACKAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"
272271
PIVOT_CACHE_DEFINITION = (
273-
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCac"
274-
"heDefinition"
272+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
275273
)
276274
PIVOT_CACHE_RECORDS = (
277275
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/spreadsh"
@@ -295,8 +293,7 @@ class RELATIONSHIP_TYPE:
295293
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata"
296294
)
297295
SIGNATURE = (
298-
"http://schemas.openxmlformats.org/package/2006/relationships/digital-signatu"
299-
"re/signature"
296+
"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature"
300297
)
301298
SLIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"
302299
SLIDE_LAYOUT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"
@@ -321,8 +318,7 @@ class RELATIONSHIP_TYPE:
321318
VIEW_PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps"
322319
VML_DRAWING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"
323320
VOLATILE_DEPENDENCIES = (
324-
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/volatile"
325-
"Dependencies"
321+
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/volatileDependencies"
326322
)
327323
WEB_SETTINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"
328324
WORKSHEET_SOURCE = (

src/pptx/opc/package.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,7 @@ def target_part(self) -> Part:
727727
"""|Part| or subtype referred to by this relationship."""
728728
if self.is_external:
729729
raise ValueError(
730-
"`.target_part` property on _Relationship is undefined when "
731-
"target-mode is external"
730+
"`.target_part` property on _Relationship is undefined when target-mode is external"
732731
)
733732
assert isinstance(self._target, Part)
734733
return self._target

0 commit comments

Comments
 (0)