Skip to content

Commit b18024d

Browse files
ShaharNavehsimonjayhawkins
authored andcommitted
STY: Whitespaces placed at the beginning instead at the end of a line (#30996)
1 parent 0f048cb commit b18024d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+150
-154
lines changed

pandas/core/arrays/categorical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,8 +2404,8 @@ def isin(self, values):
24042404
if not is_list_like(values):
24052405
values_type = type(values).__name__
24062406
raise TypeError(
2407-
"only list-like objects are allowed to be passed"
2408-
f" to isin(), you passed a [{values_type}]"
2407+
"only list-like objects are allowed to be passed "
2408+
f"to isin(), you passed a [{values_type}]"
24092409
)
24102410
values = sanitize_array(values, None, None)
24112411
null_mask = np.asarray(isna(values))

pandas/core/arrays/datetimes.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,10 @@ def __init__(self, values, dtype=_NS_DTYPE, freq=None, copy=False):
234234
values = values._data
235235

236236
if not isinstance(values, np.ndarray):
237-
msg = (
237+
raise ValueError(
238238
f"Unexpected type '{type(values).__name__}'. 'values' must be "
239239
"a DatetimeArray ndarray, or Series or Index containing one of those."
240240
)
241-
raise ValueError(msg)
242241
if values.ndim not in [1, 2]:
243242
raise ValueError("Only 1-dimensional input arrays are supported.")
244243

@@ -249,20 +248,18 @@ def __init__(self, values, dtype=_NS_DTYPE, freq=None, copy=False):
249248
values = values.view(_NS_DTYPE)
250249

251250
if values.dtype != _NS_DTYPE:
252-
msg = (
253-
"The dtype of 'values' is incorrect. Must be 'datetime64[ns]'."
254-
f" Got {values.dtype} instead."
251+
raise ValueError(
252+
"The dtype of 'values' is incorrect. Must be 'datetime64[ns]'. "
253+
f"Got {values.dtype} instead."
255254
)
256-
raise ValueError(msg)
257255

258256
dtype = _validate_dt64_dtype(dtype)
259257

260258
if freq == "infer":
261-
msg = (
259+
raise ValueError(
262260
"Frequency inference not allowed in DatetimeArray.__init__. "
263261
"Use 'pd.array()' instead."
264262
)
265-
raise ValueError(msg)
266263

267264
if copy:
268265
values = values.copy()

pandas/core/arrays/period.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ def __arrow_array__(self, type=None):
297297
# ensure we have the same freq
298298
if self.freqstr != type.freq:
299299
raise TypeError(
300-
"Not supported to convert PeriodArray to array with different"
301-
f" 'freq' ({self.freqstr} vs {type.freq})"
300+
"Not supported to convert PeriodArray to array with different "
301+
f"'freq' ({self.freqstr} vs {type.freq})"
302302
)
303303
else:
304304
raise TypeError(

pandas/core/computation/expr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ def _maybe_evaluate_binop(
466466

467467
if res.has_invalid_return_type:
468468
raise TypeError(
469-
f"unsupported operand type(s) for {res.op}:"
470-
f" '{lhs.type}' and '{rhs.type}'"
469+
f"unsupported operand type(s) for {res.op}: "
470+
f"'{lhs.type}' and '{rhs.type}'"
471471
)
472472

473473
if self.engine != "pytables":

pandas/core/generic.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ def _validate_dtype(self, dtype):
265265
# a compound dtype
266266
if dtype.kind == "V":
267267
raise NotImplementedError(
268-
"compound dtypes are not implemented"
269-
f" in the {type(self).__name__} constructor"
268+
"compound dtypes are not implemented "
269+
f"in the {type(self).__name__} constructor"
270270
)
271271

272272
return dtype
@@ -8993,11 +8993,10 @@ def tshift(
89938993
new_data = self._data.copy()
89948994
new_data.axes[block_axis] = index.shift(periods)
89958995
elif orig_freq is not None:
8996-
msg = (
8997-
f"Given freq {freq.rule_code} does not match"
8998-
f" PeriodIndex freq {orig_freq.rule_code}"
8996+
raise ValueError(
8997+
f"Given freq {freq.rule_code} does not match "
8998+
f"PeriodIndex freq {orig_freq.rule_code}"
89998999
)
9000-
raise ValueError(msg)
90019000
else:
90029001
new_data = self._data.copy()
90039002
new_data.axes[block_axis] = index.shift(periods, freq)

pandas/core/indexes/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4790,8 +4790,8 @@ def get_slice_bound(self, label, side, kind):
47904790

47914791
if side not in ("left", "right"):
47924792
raise ValueError(
4793-
f"Invalid value for side kwarg, must be either"
4794-
f" 'left' or 'right': {side}"
4793+
"Invalid value for side kwarg, must be either "
4794+
f"'left' or 'right': {side}"
47954795
)
47964796

47974797
original_label = label

pandas/core/indexes/multi.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,8 +1288,8 @@ def _get_level_number(self, level) -> int:
12881288
if level < 0:
12891289
orig_level = level - self.nlevels
12901290
raise IndexError(
1291-
f"Too many levels: Index has only {self.nlevels} levels,"
1292-
f" {orig_level} is not a valid level number"
1291+
f"Too many levels: Index has only {self.nlevels} levels, "
1292+
f"{orig_level} is not a valid level number"
12931293
)
12941294
# Note: levels are zero-based
12951295
elif level >= self.nlevels:
@@ -2171,8 +2171,8 @@ def reorder_levels(self, order):
21712171
order = [self._get_level_number(i) for i in order]
21722172
if len(order) != self.nlevels:
21732173
raise AssertionError(
2174-
f"Length of order must be same as number of levels ({self.nlevels}),"
2175-
f" got {len(order)}"
2174+
f"Length of order must be same as number of levels ({self.nlevels}), "
2175+
f"got {len(order)}"
21762176
)
21772177
new_levels = [self.levels[i] for i in order]
21782178
new_codes = [self.codes[i] for i in order]
@@ -2527,8 +2527,8 @@ def slice_locs(self, start=None, end=None, step=None, kind=None):
25272527
def _partial_tup_index(self, tup, side="left"):
25282528
if len(tup) > self.lexsort_depth:
25292529
raise UnsortedIndexError(
2530-
f"Key length ({len(tup)}) was greater than MultiIndex lexsort depth"
2531-
f" ({self.lexsort_depth})"
2530+
f"Key length ({len(tup)}) was greater than MultiIndex lexsort depth "
2531+
f"({self.lexsort_depth})"
25322532
)
25332533

25342534
n = len(tup)

pandas/core/series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,8 +1404,8 @@ def to_string(
14041404
# catch contract violations
14051405
if not isinstance(result, str):
14061406
raise AssertionError(
1407-
"result must be of type str, type"
1408-
f" of result is {repr(type(result).__name__)}"
1407+
"result must be of type str, type "
1408+
f"of result is {repr(type(result).__name__)}"
14091409
)
14101410

14111411
if buf is None:

pandas/io/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ def get_handle(
406406
raise ValueError(f"Zero files found in ZIP file {path_or_buf}")
407407
else:
408408
raise ValueError(
409-
"Multiple files found in ZIP file."
410-
f" Only one file per ZIP: {zip_names}"
409+
"Multiple files found in ZIP file. "
410+
f"Only one file per ZIP: {zip_names}"
411411
)
412412

413413
# XZ Compression

pandas/io/parsers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,8 @@ def _get_options_with_defaults(self, engine):
906906
pass
907907
else:
908908
raise ValueError(
909-
f"The {repr(argname)} option is not supported with the"
910-
f" {repr(engine)} engine"
909+
f"The {repr(argname)} option is not supported with the "
910+
f"{repr(engine)} engine"
911911
)
912912
else:
913913
value = _deprecated_defaults.get(argname, default)

pandas/tests/arrays/categorical/test_operators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ def test_comparisons(self):
9797
# comparison (in both directions) with Series will raise
9898
s = Series(["b", "b", "b"])
9999
msg = (
100-
"Cannot compare a Categorical for op __gt__ with type"
101-
r" <class 'numpy\.ndarray'>"
100+
"Cannot compare a Categorical for op __gt__ with type "
101+
r"<class 'numpy\.ndarray'>"
102102
)
103103
with pytest.raises(TypeError, match=msg):
104104
cat > s
@@ -265,8 +265,8 @@ def test_comparisons(self, data, reverse, base):
265265
# categorical cannot be compared to Series or numpy array, and also
266266
# not the other way around
267267
msg = (
268-
"Cannot compare a Categorical for op __gt__ with type"
269-
r" <class 'numpy\.ndarray'>"
268+
"Cannot compare a Categorical for op __gt__ with type "
269+
r"<class 'numpy\.ndarray'>"
270270
)
271271
with pytest.raises(TypeError, match=msg):
272272
cat > s

pandas/tests/computation/test_eval.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ def check_operands(left, right, cmp_op):
274274
def check_simple_cmp_op(self, lhs, cmp1, rhs):
275275
ex = f"lhs {cmp1} rhs"
276276
msg = (
277-
r"only list-like( or dict-like)? objects are allowed to be"
278-
r" passed to (DataFrame\.)?isin\(\), you passed a"
279-
r" (\[|')bool(\]|')|"
277+
r"only list-like( or dict-like)? objects are allowed to be "
278+
r"passed to (DataFrame\.)?isin\(\), you passed a "
279+
r"(\[|')bool(\]|')|"
280280
"argument of type 'bool' is not iterable"
281281
)
282282
if cmp1 in ("in", "not in") and not is_list_like(rhs):
@@ -408,9 +408,9 @@ def check_compound_invert_op(self, lhs, cmp1, rhs):
408408
ex = f"~(lhs {cmp1} rhs)"
409409

410410
msg = (
411-
r"only list-like( or dict-like)? objects are allowed to be"
412-
r" passed to (DataFrame\.)?isin\(\), you passed a"
413-
r" (\[|')float(\]|')|"
411+
r"only list-like( or dict-like)? objects are allowed to be "
412+
r"passed to (DataFrame\.)?isin\(\), you passed a "
413+
r"(\[|')float(\]|')|"
414414
"argument of type 'float' is not iterable"
415415
)
416416
if is_scalar(rhs) and cmp1 in skip_these:

pandas/tests/frame/indexing/test_indexing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ def test_setitem(self, float_frame):
447447
tm.assert_series_equal(series, float_frame["col6"], check_names=False)
448448

449449
msg = (
450-
r"\"None of \[Float64Index\(\[.*dtype='float64'\)\] are in the"
451-
r" \[columns\]\""
450+
r"\"None of \[Float64Index\(\[.*dtype='float64'\)\] are in the "
451+
r"\[columns\]\""
452452
)
453453
with pytest.raises(KeyError, match=msg):
454454
float_frame[np.random.randn(len(float_frame) + 1)] = 1
@@ -1039,9 +1039,9 @@ def test_getitem_setitem_float_labels(self):
10391039

10401040
# positional slicing only via iloc!
10411041
msg = (
1042-
"cannot do slice indexing on"
1043-
r" <class 'pandas\.core\.indexes\.numeric\.Float64Index'> with"
1044-
r" these indexers \[1.0\] of <class 'float'>"
1042+
"cannot do slice indexing on "
1043+
r"<class 'pandas\.core\.indexes\.numeric\.Float64Index'> with "
1044+
r"these indexers \[1.0\] of <class 'float'>"
10451045
)
10461046
with pytest.raises(TypeError, match=msg):
10471047
df.iloc[1.0:5]

pandas/tests/frame/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ def test_swapaxes(self):
382382
tm.assert_frame_equal(df.T, df.swapaxes(1, 0))
383383
tm.assert_frame_equal(df, df.swapaxes(0, 0))
384384
msg = (
385-
"No axis named 2 for object type"
386-
r" <class 'pandas.core(.sparse)?.frame.(Sparse)?DataFrame'>"
385+
"No axis named 2 for object type "
386+
r"<class 'pandas.core(.sparse)?.frame.(Sparse)?DataFrame'>"
387387
)
388388
with pytest.raises(ValueError, match=msg):
389389
df.swapaxes(2, 5)

pandas/tests/frame/test_constructors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,9 +1854,9 @@ def check(df):
18541854
# No NaN found -> error
18551855
if len(indexer) == 0:
18561856
msg = (
1857-
"cannot do label indexing on"
1858-
r" <class 'pandas\.core\.indexes\.range\.RangeIndex'>"
1859-
r" with these indexers \[nan\] of <class 'float'>"
1857+
"cannot do label indexing on "
1858+
r"<class 'pandas\.core\.indexes\.range\.RangeIndex'> "
1859+
r"with these indexers \[nan\] of <class 'float'>"
18601860
)
18611861
with pytest.raises(TypeError, match=msg):
18621862
df.loc[:, np.nan]

pandas/tests/frame/test_dtypes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -897,15 +897,15 @@ def test_astype_to_incorrect_datetimelike(self, unit):
897897

898898
df = DataFrame(np.array([[1, 2, 3]], dtype=dtype))
899899
msg = (
900-
r"cannot astype a datetimelike from \[datetime64\[ns\]\] to"
901-
r" \[timedelta64\[{}\]\]"
900+
r"cannot astype a datetimelike from \[datetime64\[ns\]\] to "
901+
r"\[timedelta64\[{}\]\]"
902902
).format(unit)
903903
with pytest.raises(TypeError, match=msg):
904904
df.astype(other)
905905

906906
msg = (
907-
r"cannot astype a timedelta from \[timedelta64\[ns\]\] to"
908-
r" \[datetime64\[{}\]\]"
907+
r"cannot astype a timedelta from \[timedelta64\[ns\]\] to "
908+
r"\[datetime64\[{}\]\]"
909909
).format(unit)
910910
df = DataFrame(np.array([[1, 2, 3]], dtype=other))
911911
with pytest.raises(TypeError, match=msg):

pandas/tests/indexes/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class Base:
3737
def test_pickle_compat_construction(self):
3838
# need an object to create with
3939
msg = (
40-
r"Index\(\.\.\.\) must be called with a collection of some"
41-
r" kind, None was passed|"
40+
r"Index\(\.\.\.\) must be called with a collection of some "
41+
r"kind, None was passed|"
4242
r"__new__\(\) missing 1 required positional argument: 'data'|"
4343
r"__new__\(\) takes at least 2 arguments \(1 given\)"
4444
)

pandas/tests/indexes/datetimes/test_constructors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,8 @@ def test_constructor_dtype(self):
644644
)
645645

646646
msg = (
647-
"cannot supply both a tz and a timezone-naive dtype"
648-
r" \(i\.e\. datetime64\[ns\]\)"
647+
"cannot supply both a tz and a timezone-naive dtype "
648+
r"\(i\.e\. datetime64\[ns\]\)"
649649
)
650650
with pytest.raises(ValueError, match=msg):
651651
DatetimeIndex(idx, dtype="datetime64[ns]")

pandas/tests/indexes/multi/test_analytics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ def test_numpy_ufuncs(idx, func):
334334
else:
335335
expected_exception = TypeError
336336
msg = (
337-
"loop of ufunc does not support argument 0 of type tuple which"
338-
f" has no callable {func.__name__} method"
337+
"loop of ufunc does not support argument 0 of type tuple which "
338+
f"has no callable {func.__name__} method"
339339
)
340340
with pytest.raises(expected_exception, match=msg):
341341
func(idx)

pandas/tests/indexes/period/test_indexing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ def test_get_loc(self):
409409
idx0.get_loc(1.1)
410410

411411
msg = (
412-
r"'PeriodIndex\(\['2017-09-01', '2017-09-02', '2017-09-03'\],"
413-
r" dtype='period\[D\]', freq='D'\)' is an invalid key"
412+
r"'PeriodIndex\(\['2017-09-01', '2017-09-02', '2017-09-03'\], "
413+
r"dtype='period\[D\]', freq='D'\)' is an invalid key"
414414
)
415415
with pytest.raises(TypeError, match=msg):
416416
idx0.get_loc(idx0)
@@ -434,8 +434,8 @@ def test_get_loc(self):
434434
idx1.get_loc(1.1)
435435

436436
msg = (
437-
r"'PeriodIndex\(\['2017-09-02', '2017-09-02', '2017-09-03'\],"
438-
r" dtype='period\[D\]', freq='D'\)' is an invalid key"
437+
r"'PeriodIndex\(\['2017-09-02', '2017-09-02', '2017-09-03'\], "
438+
r"dtype='period\[D\]', freq='D'\)' is an invalid key"
439439
)
440440
with pytest.raises(TypeError, match=msg):
441441
idx1.get_loc(idx1)

pandas/tests/indexes/test_numeric.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ def test_constructor_invalid(self):
188188

189189
# invalid
190190
msg = (
191-
r"Float64Index\(\.\.\.\) must be called with a collection of"
192-
r" some kind, 0\.0 was passed"
191+
r"Float64Index\(\.\.\.\) must be called with a collection of "
192+
r"some kind, 0\.0 was passed"
193193
)
194194
with pytest.raises(TypeError, match=msg):
195195
Float64Index(0.0)

0 commit comments

Comments
 (0)