Skip to content

Commit 421f654

Browse files
authored
Replace old string formatting syntax with f-strings (#32122)
1 parent 74181e1 commit 421f654

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

scripts/validate_docstrings.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,12 @@ def pandas_validate(func_name: str):
243243
"EX03",
244244
error_code=err.error_code,
245245
error_message=err.message,
246-
times_happening=" ({} times)".format(err.count)
247-
if err.count > 1
248-
else "",
246+
times_happening=f" ({err.count} times)" if err.count > 1 else "",
249247
)
250248
)
251249
examples_source_code = "".join(doc.examples_source_code)
252250
for wrong_import in ("numpy", "pandas"):
253-
if "import {}".format(wrong_import) in examples_source_code:
251+
if f"import {wrong_import}" in examples_source_code:
254252
result["errors"].append(
255253
pandas_error("EX04", imported_library=wrong_import)
256254
)
@@ -345,9 +343,7 @@ def header(title, width=80, char="#"):
345343
full_line = char * width
346344
side_len = (width - len(title) - 2) // 2
347345
adj = "" if len(title) % 2 == 0 else " "
348-
title_line = "{side} {title}{adj} {side}".format(
349-
side=char * side_len, title=title, adj=adj
350-
)
346+
title_line = f"{char * side_len} {title}{adj} {char * side_len}"
351347

352348
return f"\n{full_line}\n{title_line}\n{full_line}\n\n"
353349

0 commit comments

Comments
 (0)