From b4a97bf7cdd2ab9f980744c338c9598fba0bbcdf Mon Sep 17 00:00:00 2001
From: Patrick
Date: Sat, 15 Feb 2020 17:56:43 +0000
Subject: [PATCH 1/4] CLN: GH29547 replace old string formatting
---
pandas/tests/arrays/categorical/test_analytics.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pandas/tests/arrays/categorical/test_analytics.py b/pandas/tests/arrays/categorical/test_analytics.py
index 90fcf12093909..0ff7d3e59abb3 100644
--- a/pandas/tests/arrays/categorical/test_analytics.py
+++ b/pandas/tests/arrays/categorical/test_analytics.py
@@ -15,10 +15,10 @@ class TestCategoricalAnalytics:
def test_min_max_not_ordered_raises(self, aggregation):
# unordered cats have no min/max
cat = Categorical(["a", "b", "c", "d"], ordered=False)
- msg = "Categorical is not ordered for operation {}"
+ msg = f"Categorical is not ordered for operation {aggregation}"
agg_func = getattr(cat, aggregation)
- with pytest.raises(TypeError, match=msg.format(aggregation)):
+ with pytest.raises(TypeError, match=msg):
agg_func()
def test_min_max_ordered(self):
From 49a958c386385d1baf2b8e2ca1ebe77657fa7ae3 Mon Sep 17 00:00:00 2001
From: Patrick
Date: Mon, 17 Feb 2020 16:41:41 +0000
Subject: [PATCH 2/4] CLN: GH29547 replace old string formatting: tslib
---
pandas/tests/tslibs/test_parse_iso8601.py | 2 +-
pandas/tests/tslibs/test_parsing.py | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/pandas/tests/tslibs/test_parse_iso8601.py b/pandas/tests/tslibs/test_parse_iso8601.py
index a58f227c20c7f..1c01e826d9794 100644
--- a/pandas/tests/tslibs/test_parse_iso8601.py
+++ b/pandas/tests/tslibs/test_parse_iso8601.py
@@ -51,7 +51,7 @@ def test_parsers_iso8601(date_str, exp):
],
)
def test_parsers_iso8601_invalid(date_str):
- msg = 'Error parsing datetime string "{s}"'.format(s=date_str)
+ msg = f'Error parsing datetime string "{date_str}"'
with pytest.raises(ValueError, match=msg):
tslib._test_parse_iso8601(date_str)
diff --git a/pandas/tests/tslibs/test_parsing.py b/pandas/tests/tslibs/test_parsing.py
index c452d5b12ce01..1ba7832c47e6c 100644
--- a/pandas/tests/tslibs/test_parsing.py
+++ b/pandas/tests/tslibs/test_parsing.py
@@ -42,9 +42,9 @@ def test_parse_time_quarter_with_dash(dashed, normal):
@pytest.mark.parametrize("dashed", ["-2Q1992", "2-Q1992", "4-4Q1992"])
def test_parse_time_quarter_with_dash_error(dashed):
- msg = "Unknown datetime string format, unable to parse: {dashed}"
+ msg = f"Unknown datetime string format, unable to parse: {dashed}"
- with pytest.raises(parsing.DateParseError, match=msg.format(dashed=dashed)):
+ with pytest.raises(parsing.DateParseError, match=msg):
parse_time_string(dashed)
@@ -115,12 +115,12 @@ def test_parsers_quarter_invalid(date_str):
if date_str == "6Q-20":
msg = (
"Incorrect quarterly string is given, quarter "
- "must be between 1 and 4: {date_str}"
+ f"must be between 1 and 4: {date_str}"
)
else:
- msg = "Unknown datetime string format, unable to parse: {date_str}"
+ msg = f"Unknown datetime string format, unable to parse: {date_str}"
- with pytest.raises(ValueError, match=msg.format(date_str=date_str)):
+ with pytest.raises(ValueError, match=msg):
parsing.parse_time_string(date_str)
From 2eae8c530dc49ec3c88ef85ba26803c0149a87ce Mon Sep 17 00:00:00 2001
From: Patrick
Date: Mon, 17 Feb 2020 16:46:20 +0000
Subject: [PATCH 3/4] CLN: GH29547 replace old str formatting: tseries
---
pandas/tests/tseries/frequencies/test_inference.py | 10 +++++-----
pandas/tests/tseries/frequencies/test_to_offset.py | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/pandas/tests/tseries/frequencies/test_inference.py b/pandas/tests/tseries/frequencies/test_inference.py
index c4660417599a8..6e40d7effb8c7 100644
--- a/pandas/tests/tseries/frequencies/test_inference.py
+++ b/pandas/tests/tseries/frequencies/test_inference.py
@@ -178,7 +178,7 @@ def test_infer_freq_delta(base_delta_code_pair, count):
inc = base_delta * count
index = DatetimeIndex([b + inc * j for j in range(3)])
- exp_freq = "{count:d}{code}".format(count=count, code=code) if count > 1 else code
+ exp_freq = f"{count:d}{code}" if count > 1 else code
assert frequencies.infer_freq(index) == exp_freq
@@ -202,12 +202,12 @@ def test_infer_freq_custom(base_delta_code_pair, constructor):
def test_weekly_infer(periods, day):
- _check_generated_range("1/1/2000", periods, "W-{day}".format(day=day))
+ _check_generated_range("1/1/2000", periods, f"W-{day}")
def test_week_of_month_infer(periods, day, count):
_check_generated_range(
- "1/1/2000", periods, "WOM-{count}{day}".format(count=count, day=day)
+ "1/1/2000", periods, f"WOM-{count}{day}"
)
@@ -217,13 +217,13 @@ def test_monthly_infer(periods, freq):
def test_quarterly_infer(month, periods):
- _check_generated_range("1/1/2000", periods, "Q-{month}".format(month=month))
+ _check_generated_range("1/1/2000", periods, f"Q-{month}")
@pytest.mark.parametrize("annual", ["A", "BA"])
def test_annually_infer(month, periods, annual):
_check_generated_range(
- "1/1/2000", periods, "{annual}-{month}".format(annual=annual, month=month)
+ "1/1/2000", periods, f"{annual}-{month}"
)
diff --git a/pandas/tests/tseries/frequencies/test_to_offset.py b/pandas/tests/tseries/frequencies/test_to_offset.py
index b6069c446160d..beaefe9109e91 100644
--- a/pandas/tests/tseries/frequencies/test_to_offset.py
+++ b/pandas/tests/tseries/frequencies/test_to_offset.py
@@ -86,7 +86,7 @@ def test_to_offset_invalid(freqstr):
# We escape string because some of our
# inputs contain regex special characters.
- msg = re.escape("Invalid frequency: {freqstr}".format(freqstr=freqstr))
+ msg = re.escape(f"Invalid frequency: {freqstr}")
with pytest.raises(ValueError, match=msg):
frequencies.to_offset(freqstr)
From fc40ac194915a31d6069f3664e752a771683ac7a Mon Sep 17 00:00:00 2001
From: Patrick
Date: Mon, 17 Feb 2020 16:51:44 +0000
Subject: [PATCH 4/4] CLN: GH29547 black format update
---
pandas/tests/tseries/frequencies/test_inference.py | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/pandas/tests/tseries/frequencies/test_inference.py b/pandas/tests/tseries/frequencies/test_inference.py
index 6e40d7effb8c7..c32ad5087ab9e 100644
--- a/pandas/tests/tseries/frequencies/test_inference.py
+++ b/pandas/tests/tseries/frequencies/test_inference.py
@@ -206,9 +206,7 @@ def test_weekly_infer(periods, day):
def test_week_of_month_infer(periods, day, count):
- _check_generated_range(
- "1/1/2000", periods, f"WOM-{count}{day}"
- )
+ _check_generated_range("1/1/2000", periods, f"WOM-{count}{day}")
@pytest.mark.parametrize("freq", ["M", "BM", "BMS"])
@@ -222,9 +220,7 @@ def test_quarterly_infer(month, periods):
@pytest.mark.parametrize("annual", ["A", "BA"])
def test_annually_infer(month, periods, annual):
- _check_generated_range(
- "1/1/2000", periods, f"{annual}-{month}"
- )
+ _check_generated_range("1/1/2000", periods, f"{annual}-{month}")
@pytest.mark.parametrize(