Skip to content

Commit 7f3d7b9

Browse files
ShaharNavehjreback
authored andcommitted
STY: Removed unconcatenated strings (#30464)
1 parent 3029d8f commit 7f3d7b9

29 files changed

+48
-86
lines changed

pandas/core/arrays/datetimelike.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,9 +916,7 @@ def _is_unique(self):
916916

917917
def _add_datetimelike_scalar(self, other):
918918
# Overriden by TimedeltaArray
919-
raise TypeError(
920-
f"cannot add {type(self).__name__} and " f"{type(other).__name__}"
921-
)
919+
raise TypeError(f"cannot add {type(self).__name__} and {type(other).__name__}")
922920

923921
_add_datetime_arraylike = _add_datetimelike_scalar
924922

pandas/core/dtypes/cast.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,7 @@ def astype_nansafe(arr, dtype, copy: bool = True, skipna: bool = False):
820820
if dtype.kind == "M":
821821
return arr.astype(dtype)
822822

823-
raise TypeError(
824-
f"cannot astype a datetimelike from [{arr.dtype}] " f"to [{dtype}]"
825-
)
823+
raise TypeError(f"cannot astype a datetimelike from [{arr.dtype}] to [{dtype}]")
826824

827825
elif is_timedelta64_dtype(arr):
828826
if is_object_dtype(dtype):
@@ -842,9 +840,7 @@ def astype_nansafe(arr, dtype, copy: bool = True, skipna: bool = False):
842840
elif dtype == _TD_DTYPE:
843841
return arr.astype(_TD_DTYPE, copy=copy)
844842

845-
raise TypeError(
846-
f"cannot astype a timedelta from [{arr.dtype}] " f"to [{dtype}]"
847-
)
843+
raise TypeError(f"cannot astype a timedelta from [{arr.dtype}] to [{dtype}]")
848844

849845
elif np.issubdtype(arr.dtype, np.floating) and np.issubdtype(dtype, np.integer):
850846

pandas/io/json/_json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def to_json(
5353

5454
if not index and orient not in ["split", "table"]:
5555
raise ValueError(
56-
"'index=False' is only valid when 'orient' is " "'split' or 'table'"
56+
"'index=False' is only valid when 'orient' is 'split' or 'table'"
5757
)
5858

5959
path_or_buf = stringify_path(path_or_buf)

pandas/io/json/_table_schema.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ def set_default_names(data):
8181
if len(nms) == 1 and data.index.name == "index":
8282
warnings.warn("Index name of 'index' is not round-trippable")
8383
elif len(nms) > 1 and any(x.startswith("level_") for x in nms):
84-
warnings.warn(
85-
"Index names beginning with 'level_' are not " "round-trippable"
86-
)
84+
warnings.warn("Index names beginning with 'level_' are not round-trippable")
8785
return data
8886

8987
data = data.copy()
@@ -317,12 +315,12 @@ def parse_table_schema(json, precise_float):
317315

318316
# Cannot directly use as_type with timezone data on object; raise for now
319317
if any(str(x).startswith("datetime64[ns, ") for x in dtypes.values()):
320-
raise NotImplementedError('table="orient" can not yet read timezone ' "data")
318+
raise NotImplementedError('table="orient" can not yet read timezone data')
321319

322320
# No ISO constructor for Timedelta as of yet, so need to raise
323321
if "timedelta64" in dtypes.values():
324322
raise NotImplementedError(
325-
'table="orient" can not yet read ' "ISO-formatted Timedelta data"
323+
'table="orient" can not yet read ISO-formatted Timedelta data'
326324
)
327325

328326
df = df.astype(dtypes)

pandas/tests/arithmetic/test_period.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ def test_parr_cmp_pi_mismatched_freq_raises(self, freq, box_with_array):
168168

169169
# TODO: Could parametrize over boxes for idx?
170170
idx = PeriodIndex(["2011", "2012", "2013", "2014"], freq="A")
171-
rev_msg = (
172-
r"Input has different freq=(M|2M|3M) from " r"PeriodArray\(freq=A-DEC\)"
173-
)
171+
rev_msg = r"Input has different freq=(M|2M|3M) from PeriodArray\(freq=A-DEC\)"
174172
idx_msg = rev_msg if box_with_array is tm.to_array else msg
175173
with pytest.raises(IncompatibleFrequency, match=idx_msg):
176174
base <= idx
@@ -184,7 +182,7 @@ def test_parr_cmp_pi_mismatched_freq_raises(self, freq, box_with_array):
184182
Period("2011", freq="4M") >= base
185183

186184
idx = PeriodIndex(["2011", "2012", "2013", "2014"], freq="4M")
187-
rev_msg = r"Input has different freq=(M|2M|3M) from " r"PeriodArray\(freq=4M\)"
185+
rev_msg = r"Input has different freq=(M|2M|3M) from PeriodArray\(freq=4M\)"
188186
idx_msg = rev_msg if box_with_array is tm.to_array else msg
189187
with pytest.raises(IncompatibleFrequency, match=idx_msg):
190188
base <= idx

pandas/tests/arrays/test_timedeltas.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ def test_other_type_raises(self):
4141
def test_incorrect_dtype_raises(self):
4242
# TODO: why TypeError for 'category' but ValueError for i8?
4343
with pytest.raises(
44-
ValueError, match=r"category cannot be converted " r"to timedelta64\[ns\]"
44+
ValueError, match=r"category cannot be converted to timedelta64\[ns\]"
4545
):
4646
TimedeltaArray(np.array([1, 2, 3], dtype="i8"), dtype="category")
4747

4848
with pytest.raises(
49-
ValueError,
50-
match=r"dtype int64 cannot be converted " r"to timedelta64\[ns\]",
49+
ValueError, match=r"dtype int64 cannot be converted to timedelta64\[ns\]",
5150
):
5251
TimedeltaArray(np.array([1, 2, 3], dtype="i8"), dtype=np.dtype("int64"))
5352

pandas/tests/base/test_ops.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,7 @@ def test_duplicated_drop_duplicates_index(self):
698698

699699
with pytest.raises(
700700
TypeError,
701-
match=(
702-
r"drop_duplicates\(\) got an " r"unexpected keyword argument"
703-
),
701+
match=r"drop_duplicates\(\) got an unexpected keyword argument",
704702
):
705703
idx.drop_duplicates(inplace=True)
706704

pandas/tests/frame/test_constructors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,11 @@ def test_constructor_error_msgs(self):
479479
DataFrame(np.zeros((3, 3, 3)), columns=["A", "B", "C"], index=[1])
480480

481481
# wrong size axis labels
482-
msg = "Shape of passed values " r"is \(2, 3\), indices " r"imply \(1, 3\)"
482+
msg = r"Shape of passed values is \(2, 3\), indices imply \(1, 3\)"
483483
with pytest.raises(ValueError, match=msg):
484484
DataFrame(np.random.rand(2, 3), columns=["A", "B", "C"], index=[1])
485485

486-
msg = "Shape of passed values " r"is \(2, 3\), indices " r"imply \(2, 2\)"
486+
msg = r"Shape of passed values is \(2, 3\), indices imply \(2, 2\)"
487487
with pytest.raises(ValueError, match=msg):
488488
DataFrame(np.random.rand(2, 3), columns=["A", "B"], index=[1, 2])
489489

pandas/tests/frame/test_missing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ def test_fillna_invalid_method(self, float_frame):
662662

663663
def test_fillna_invalid_value(self, float_frame):
664664
# list
665-
msg = '"value" parameter must be a scalar or dict, but you passed' ' a "{}"'
665+
msg = '"value" parameter must be a scalar or dict, but you passed a "{}"'
666666
with pytest.raises(TypeError, match=msg.format("list")):
667667
float_frame.fillna([1, 2])
668668
# tuple

pandas/tests/indexes/datetimes/test_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ def test_dataframe(self, cache):
12981298
tm.assert_series_equal(result, expected)
12991299

13001300
# extra columns
1301-
msg = "extra keys have been passed to the datetime assemblage: " r"\[foo\]"
1301+
msg = r"extra keys have been passed to the datetime assemblage: \[foo\]"
13021302
with pytest.raises(ValueError, match=msg):
13031303
df2 = df.copy()
13041304
df2["foo"] = 1

0 commit comments

Comments
 (0)