Skip to content

Commit 9853d0e

Browse files
authored
replacing .format with f-strings (#31628)
* replacing .format with f-strings * fixing invalid syntax around the variables being subbed in at the f-strings * ran pytest and black. passed.
1 parent f75f115 commit 9853d0e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pandas/tests/io/test_pickle.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ def compare_element(result, expected, typ, version=None):
6060
assert result == expected
6161
assert result.freq == expected.freq
6262
else:
63-
comparator = getattr(
64-
tm, "assert_{typ}_equal".format(typ=typ), tm.assert_almost_equal
65-
)
63+
comparator = getattr(tm, f"assert_{typ}_equal", tm.assert_almost_equal)
6664
comparator(result, expected)
6765

6866

@@ -77,7 +75,7 @@ def compare(data, vf, version):
7775

7876
# use a specific comparator
7977
# if available
80-
comparator = "compare_{typ}_{dt}".format(typ=typ, dt=dt)
78+
comparator = f"compare_{typ}_{dt}"
8179

8280
comparator = m.get(comparator, m["compare_element"])
8381
comparator(result, expected, typ, version)
@@ -234,7 +232,7 @@ def test_legacy_sparse_warning(datapath):
234232

235233
@pytest.fixture
236234
def get_random_path():
237-
return "__{}__.pickle".format(tm.rands(10))
235+
return f"__{tm.rands(10)}__.pickle"
238236

239237

240238
class TestCompression:
@@ -262,7 +260,7 @@ def compress_file(self, src_path, dest_path, compression):
262260
elif compression == "xz":
263261
f = _get_lzma_file(lzma)(dest_path, "w")
264262
else:
265-
msg = "Unrecognized compression type: {}".format(compression)
263+
msg = f"Unrecognized compression type: {compression}"
266264
raise ValueError(msg)
267265

268266
if compression != "zip":

0 commit comments

Comments
 (0)