From 72d025c80f7104902e7e1fb45350fe0a33364171 Mon Sep 17 00:00:00 2001 From: Seibert Date: Mon, 3 Feb 2020 10:40:49 -0600 Subject: [PATCH 1/4] replacing .format with f-strings --- pandas/tests/io/test_pickle.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/tests/io/test_pickle.py b/pandas/tests/io/test_pickle.py index 04fd4835469a9..7a5fd594f28a0 100644 --- a/pandas/tests/io/test_pickle.py +++ b/pandas/tests/io/test_pickle.py @@ -61,7 +61,7 @@ def compare_element(result, expected, typ, version=None): assert result.freq == expected.freq else: comparator = getattr( - tm, "assert_{typ}_equal".format(typ=typ), tm.assert_almost_equal + tm, f"assert_{typ=typ}_equal", tm.assert_almost_equal ) comparator(result, expected) @@ -77,7 +77,7 @@ def compare(data, vf, version): # use a specific comparator # if available - comparator = "compare_{typ}_{dt}".format(typ=typ, dt=dt) + comparator = f"compare_{typ=typ}_{dt=dt}" comparator = m.get(comparator, m["compare_element"]) comparator(result, expected, typ, version) @@ -234,7 +234,7 @@ def test_legacy_sparse_warning(datapath): @pytest.fixture def get_random_path(): - return "__{}__.pickle".format(tm.rands(10)) + return f"__{tm.rands(10)}__.pickle" class TestCompression: @@ -262,7 +262,7 @@ def compress_file(self, src_path, dest_path, compression): elif compression == "xz": f = _get_lzma_file(lzma)(dest_path, "w") else: - msg = "Unrecognized compression type: {}".format(compression) + msg = f"Unrecognized compression type: {compression}" raise ValueError(msg) if compression != "zip": From 225dac1991ee10f3e0d52847c7b8e9d1bc5a45b6 Mon Sep 17 00:00:00 2001 From: drewseibert Date: Mon, 3 Feb 2020 12:05:16 -0600 Subject: [PATCH 2/4] fixing invalid syntax around the variables being subbed in at the f-strings --- pandas/tests/io/test_pickle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/test_pickle.py b/pandas/tests/io/test_pickle.py index 7a5fd594f28a0..e2fddf2a94071 100644 --- a/pandas/tests/io/test_pickle.py +++ b/pandas/tests/io/test_pickle.py @@ -61,7 +61,7 @@ def compare_element(result, expected, typ, version=None): assert result.freq == expected.freq else: comparator = getattr( - tm, f"assert_{typ=typ}_equal", tm.assert_almost_equal + tm, f"assert_{typ}_equal", tm.assert_almost_equal ) comparator(result, expected) @@ -77,7 +77,7 @@ def compare(data, vf, version): # use a specific comparator # if available - comparator = f"compare_{typ=typ}_{dt=dt}" + comparator = f"compare_{typ}_{dt}" comparator = m.get(comparator, m["compare_element"]) comparator(result, expected, typ, version) From bb8d3a309fc5ade4409251c268f048fdcdd39d13 Mon Sep 17 00:00:00 2001 From: drewseibert Date: Mon, 3 Feb 2020 14:02:48 -0600 Subject: [PATCH 3/4] ran pytest and black. passed. --- pandas/tests/io/test_pickle.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/tests/io/test_pickle.py b/pandas/tests/io/test_pickle.py index e2fddf2a94071..78b630bb5ada1 100644 --- a/pandas/tests/io/test_pickle.py +++ b/pandas/tests/io/test_pickle.py @@ -60,9 +60,7 @@ def compare_element(result, expected, typ, version=None): assert result == expected assert result.freq == expected.freq else: - comparator = getattr( - tm, f"assert_{typ}_equal", tm.assert_almost_equal - ) + comparator = getattr(tm, f"assert_{typ}_equal", tm.assert_almost_equal) comparator(result, expected) From a46357c247d3c72681add0589e63ad950c151b1e Mon Sep 17 00:00:00 2001 From: drewseibert Date: Thu, 6 Feb 2020 11:31:17 -0600 Subject: [PATCH 4/4] adding f-strings to replace .format lines --- pandas/tests/series/indexing/test_indexing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/tests/series/indexing/test_indexing.py b/pandas/tests/series/indexing/test_indexing.py index 1b21e2419595f..fa5c75d5e4ad9 100644 --- a/pandas/tests/series/indexing/test_indexing.py +++ b/pandas/tests/series/indexing/test_indexing.py @@ -429,7 +429,7 @@ def test_basic_getitem_setitem_corner(datetime_series): @pytest.mark.parametrize("tz", ["US/Eastern", "UTC", "Asia/Tokyo"]) def test_setitem_with_tz(tz): orig = pd.Series(pd.date_range("2016-01-01", freq="H", periods=3, tz=tz)) - assert orig.dtype == "datetime64[ns, {0}]".format(tz) + assert orig.dtype == f"datetime64[ns, {tz}]" # scalar s = orig.copy() @@ -456,7 +456,7 @@ def test_setitem_with_tz(tz): [pd.Timestamp("2011-01-01", tz=tz), pd.Timestamp("2012-01-01", tz=tz)], index=[1, 2], ) - assert vals.dtype == "datetime64[ns, {0}]".format(tz) + assert vals.dtype == f"datetime64[ns, {tz}]" s[[1, 2]] = vals exp = pd.Series( @@ -481,7 +481,7 @@ def test_setitem_with_tz_dst(): # GH XXX tz = "US/Eastern" orig = pd.Series(pd.date_range("2016-11-06", freq="H", periods=3, tz=tz)) - assert orig.dtype == "datetime64[ns, {0}]".format(tz) + assert orig.dtype == f"datetime64[ns, {tz}]" # scalar s = orig.copy() @@ -508,7 +508,7 @@ def test_setitem_with_tz_dst(): [pd.Timestamp("2011-01-01", tz=tz), pd.Timestamp("2012-01-01", tz=tz)], index=[1, 2], ) - assert vals.dtype == "datetime64[ns, {0}]".format(tz) + assert vals.dtype == f"datetime64[ns, {tz}]" s[[1, 2]] = vals exp = pd.Series(