Skip to content

Commit 085e75e

Browse files
authored
CLN: GH29547 change string formatting with f-strings (6 files changed) (#34831)
1 parent 16dfb61 commit 085e75e

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

pandas/tests/io/parser/test_header.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,11 @@ def test_multi_index_unnamed(all_parsers, index_col, columns):
528528
parser.read_csv(StringIO(data), header=header, index_col=index_col)
529529
else:
530530
result = parser.read_csv(StringIO(data), header=header, index_col=index_col)
531-
template = "Unnamed: {i}_level_0"
532531
exp_columns = []
533532

534533
for i, col in enumerate(columns):
535534
if not col: # Unnamed.
536-
col = template.format(i=i if index_col is None else i + 1)
535+
col = f"Unnamed: {i if index_col is None else i + 1}_level_0"
537536

538537
exp_columns.append(col)
539538

pandas/tests/io/test_sql.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1900,9 +1900,9 @@ class _TestMySQLAlchemy:
19001900

19011901
@classmethod
19021902
def connect(cls):
1903-
url = "mysql+{driver}://root@localhost/pandas_nosetest"
19041903
return sqlalchemy.create_engine(
1905-
url.format(driver=cls.driver), connect_args=cls.connect_args
1904+
f"mysql+{cls.driver}://root@localhost/pandas_nosetest",
1905+
connect_args=cls.connect_args,
19061906
)
19071907

19081908
@classmethod
@@ -1969,8 +1969,9 @@ class _TestPostgreSQLAlchemy:
19691969

19701970
@classmethod
19711971
def connect(cls):
1972-
url = "postgresql+{driver}://postgres@localhost/pandas_nosetest"
1973-
return sqlalchemy.create_engine(url.format(driver=cls.driver))
1972+
return sqlalchemy.create_engine(
1973+
f"postgresql+{cls.driver}://postgres@localhost/pandas_nosetest"
1974+
)
19741975

19751976
@classmethod
19761977
def setup_driver(cls):

pandas/tests/reductions/test_reductions.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,10 @@ def test_invalid_td64_reductions(self, opname):
349349

350350
msg = "|".join(
351351
[
352-
"reduction operation '{op}' not allowed for this dtype",
353-
r"cannot perform {op} with type timedelta64\[ns\]",
352+
f"reduction operation '{opname}' not allowed for this dtype",
353+
rf"cannot perform {opname} with type timedelta64\[ns\]",
354354
]
355355
)
356-
msg = msg.format(op=opname)
357356

358357
with pytest.raises(TypeError, match=msg):
359358
getattr(td, opname)()

0 commit comments

Comments
 (0)