Skip to content

STY: Whitespaces placed at the beginning instead at the end of a line #30996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2404,8 +2404,8 @@ def isin(self, values):
if not is_list_like(values):
values_type = type(values).__name__
raise TypeError(
"only list-like objects are allowed to be passed"
f" to isin(), you passed a [{values_type}]"
"only list-like objects are allowed to be passed "
f"to isin(), you passed a [{values_type}]"
)
values = sanitize_array(values, None, None)
null_mask = np.asarray(isna(values))
Expand Down
13 changes: 5 additions & 8 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,10 @@ def __init__(self, values, dtype=_NS_DTYPE, freq=None, copy=False):
values = values._data

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

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

if values.dtype != _NS_DTYPE:
msg = (
"The dtype of 'values' is incorrect. Must be 'datetime64[ns]'."
f" Got {values.dtype} instead."
raise ValueError(
"The dtype of 'values' is incorrect. Must be 'datetime64[ns]'. "
f"Got {values.dtype} instead."
)
raise ValueError(msg)

dtype = _validate_dt64_dtype(dtype)

if freq == "infer":
msg = (
raise ValueError(
"Frequency inference not allowed in DatetimeArray.__init__. "
"Use 'pd.array()' instead."
)
raise ValueError(msg)

if copy:
values = values.copy()
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ def __arrow_array__(self, type=None):
# ensure we have the same freq
if self.freqstr != type.freq:
raise TypeError(
"Not supported to convert PeriodArray to array with different"
f" 'freq' ({self.freqstr} vs {type.freq})"
"Not supported to convert PeriodArray to array with different "
f"'freq' ({self.freqstr} vs {type.freq})"
)
else:
raise TypeError(
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/computation/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ def _maybe_evaluate_binop(

if res.has_invalid_return_type:
raise TypeError(
f"unsupported operand type(s) for {res.op}:"
f" '{lhs.type}' and '{rhs.type}'"
f"unsupported operand type(s) for {res.op}: "
f"'{lhs.type}' and '{rhs.type}'"
)

if self.engine != "pytables":
Expand Down
11 changes: 5 additions & 6 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ def _validate_dtype(self, dtype):
# a compound dtype
if dtype.kind == "V":
raise NotImplementedError(
"compound dtypes are not implemented"
f" in the {type(self).__name__} constructor"
"compound dtypes are not implemented "
f"in the {type(self).__name__} constructor"
)

return dtype
Expand Down Expand Up @@ -8993,11 +8993,10 @@ def tshift(
new_data = self._data.copy()
new_data.axes[block_axis] = index.shift(periods)
elif orig_freq is not None:
msg = (
f"Given freq {freq.rule_code} does not match"
f" PeriodIndex freq {orig_freq.rule_code}"
raise ValueError(
f"Given freq {freq.rule_code} does not match "
f"PeriodIndex freq {orig_freq.rule_code}"
)
raise ValueError(msg)
else:
new_data = self._data.copy()
new_data.axes[block_axis] = index.shift(periods, freq)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4790,8 +4790,8 @@ def get_slice_bound(self, label, side, kind):

if side not in ("left", "right"):
raise ValueError(
f"Invalid value for side kwarg, must be either"
f" 'left' or 'right': {side}"
"Invalid value for side kwarg, must be either "
f"'left' or 'right': {side}"
)

original_label = label
Expand Down
12 changes: 6 additions & 6 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,8 +1288,8 @@ def _get_level_number(self, level) -> int:
if level < 0:
orig_level = level - self.nlevels
raise IndexError(
f"Too many levels: Index has only {self.nlevels} levels,"
f" {orig_level} is not a valid level number"
f"Too many levels: Index has only {self.nlevels} levels, "
f"{orig_level} is not a valid level number"
)
# Note: levels are zero-based
elif level >= self.nlevels:
Expand Down Expand Up @@ -2171,8 +2171,8 @@ def reorder_levels(self, order):
order = [self._get_level_number(i) for i in order]
if len(order) != self.nlevels:
raise AssertionError(
f"Length of order must be same as number of levels ({self.nlevels}),"
f" got {len(order)}"
f"Length of order must be same as number of levels ({self.nlevels}), "
f"got {len(order)}"
)
new_levels = [self.levels[i] for i in order]
new_codes = [self.codes[i] for i in order]
Expand Down Expand Up @@ -2527,8 +2527,8 @@ def slice_locs(self, start=None, end=None, step=None, kind=None):
def _partial_tup_index(self, tup, side="left"):
if len(tup) > self.lexsort_depth:
raise UnsortedIndexError(
f"Key length ({len(tup)}) was greater than MultiIndex lexsort depth"
f" ({self.lexsort_depth})"
f"Key length ({len(tup)}) was greater than MultiIndex lexsort depth "
f"({self.lexsort_depth})"
)

n = len(tup)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,8 +1404,8 @@ def to_string(
# catch contract violations
if not isinstance(result, str):
raise AssertionError(
"result must be of type str, type"
f" of result is {repr(type(result).__name__)}"
"result must be of type str, type "
f"of result is {repr(type(result).__name__)}"
)

if buf is None:
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ def get_handle(
raise ValueError(f"Zero files found in ZIP file {path_or_buf}")
else:
raise ValueError(
"Multiple files found in ZIP file."
f" Only one file per ZIP: {zip_names}"
"Multiple files found in ZIP file. "
f"Only one file per ZIP: {zip_names}"
)

# XZ Compression
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,8 @@ def _get_options_with_defaults(self, engine):
pass
else:
raise ValueError(
f"The {repr(argname)} option is not supported with the"
f" {repr(engine)} engine"
f"The {repr(argname)} option is not supported with the "
f"{repr(engine)} engine"
)
else:
value = _deprecated_defaults.get(argname, default)
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/arrays/categorical/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def test_comparisons(self):
# comparison (in both directions) with Series will raise
s = Series(["b", "b", "b"])
msg = (
"Cannot compare a Categorical for op __gt__ with type"
r" <class 'numpy\.ndarray'>"
"Cannot compare a Categorical for op __gt__ with type "
r"<class 'numpy\.ndarray'>"
)
with pytest.raises(TypeError, match=msg):
cat > s
Expand Down Expand Up @@ -265,8 +265,8 @@ def test_comparisons(self, data, reverse, base):
# categorical cannot be compared to Series or numpy array, and also
# not the other way around
msg = (
"Cannot compare a Categorical for op __gt__ with type"
r" <class 'numpy\.ndarray'>"
"Cannot compare a Categorical for op __gt__ with type "
r"<class 'numpy\.ndarray'>"
)
with pytest.raises(TypeError, match=msg):
cat > s
Expand Down
12 changes: 6 additions & 6 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ def check_operands(left, right, cmp_op):
def check_simple_cmp_op(self, lhs, cmp1, rhs):
ex = f"lhs {cmp1} rhs"
msg = (
r"only list-like( or dict-like)? objects are allowed to be"
r" passed to (DataFrame\.)?isin\(\), you passed a"
r" (\[|')bool(\]|')|"
r"only list-like( or dict-like)? objects are allowed to be "
r"passed to (DataFrame\.)?isin\(\), you passed a "
r"(\[|')bool(\]|')|"
"argument of type 'bool' is not iterable"
)
if cmp1 in ("in", "not in") and not is_list_like(rhs):
Expand Down Expand Up @@ -408,9 +408,9 @@ def check_compound_invert_op(self, lhs, cmp1, rhs):
ex = f"~(lhs {cmp1} rhs)"

msg = (
r"only list-like( or dict-like)? objects are allowed to be"
r" passed to (DataFrame\.)?isin\(\), you passed a"
r" (\[|')float(\]|')|"
r"only list-like( or dict-like)? objects are allowed to be "
r"passed to (DataFrame\.)?isin\(\), you passed a "
r"(\[|')float(\]|')|"
"argument of type 'float' is not iterable"
)
if is_scalar(rhs) and cmp1 in skip_these:
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ def test_setitem(self, float_frame):
tm.assert_series_equal(series, float_frame["col6"], check_names=False)

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

# positional slicing only via iloc!
msg = (
"cannot do slice indexing on"
r" <class 'pandas\.core\.indexes\.numeric\.Float64Index'> with"
r" these indexers \[1.0\] of <class 'float'>"
"cannot do slice indexing on "
r"<class 'pandas\.core\.indexes\.numeric\.Float64Index'> with "
r"these indexers \[1.0\] of <class 'float'>"
)
with pytest.raises(TypeError, match=msg):
df.iloc[1.0:5]
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ def test_swapaxes(self):
tm.assert_frame_equal(df.T, df.swapaxes(1, 0))
tm.assert_frame_equal(df, df.swapaxes(0, 0))
msg = (
"No axis named 2 for object type"
r" <class 'pandas.core(.sparse)?.frame.(Sparse)?DataFrame'>"
"No axis named 2 for object type "
r"<class 'pandas.core(.sparse)?.frame.(Sparse)?DataFrame'>"
)
with pytest.raises(ValueError, match=msg):
df.swapaxes(2, 5)
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,9 +1854,9 @@ def check(df):
# No NaN found -> error
if len(indexer) == 0:
msg = (
"cannot do label indexing on"
r" <class 'pandas\.core\.indexes\.range\.RangeIndex'>"
r" with these indexers \[nan\] of <class 'float'>"
"cannot do label indexing on "
r"<class 'pandas\.core\.indexes\.range\.RangeIndex'> "
r"with these indexers \[nan\] of <class 'float'>"
)
with pytest.raises(TypeError, match=msg):
df.loc[:, np.nan]
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/frame/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,15 +897,15 @@ def test_astype_to_incorrect_datetimelike(self, unit):

df = DataFrame(np.array([[1, 2, 3]], dtype=dtype))
msg = (
r"cannot astype a datetimelike from \[datetime64\[ns\]\] to"
r" \[timedelta64\[{}\]\]"
r"cannot astype a datetimelike from \[datetime64\[ns\]\] to "
r"\[timedelta64\[{}\]\]"
).format(unit)
with pytest.raises(TypeError, match=msg):
df.astype(other)

msg = (
r"cannot astype a timedelta from \[timedelta64\[ns\]\] to"
r" \[datetime64\[{}\]\]"
r"cannot astype a timedelta from \[timedelta64\[ns\]\] to "
r"\[datetime64\[{}\]\]"
).format(unit)
df = DataFrame(np.array([[1, 2, 3]], dtype=other))
with pytest.raises(TypeError, match=msg):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class Base:
def test_pickle_compat_construction(self):
# need an object to create with
msg = (
r"Index\(\.\.\.\) must be called with a collection of some"
r" kind, None was passed|"
r"Index\(\.\.\.\) must be called with a collection of some "
r"kind, None was passed|"
r"__new__\(\) missing 1 required positional argument: 'data'|"
r"__new__\(\) takes at least 2 arguments \(1 given\)"
)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/datetimes/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@ def test_constructor_dtype(self):
)

msg = (
"cannot supply both a tz and a timezone-naive dtype"
r" \(i\.e\. datetime64\[ns\]\)"
"cannot supply both a tz and a timezone-naive dtype "
r"\(i\.e\. datetime64\[ns\]\)"
)
with pytest.raises(ValueError, match=msg):
DatetimeIndex(idx, dtype="datetime64[ns]")
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/multi/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ def test_numpy_ufuncs(idx, func):
else:
expected_exception = TypeError
msg = (
"loop of ufunc does not support argument 0 of type tuple which"
f" has no callable {func.__name__} method"
"loop of ufunc does not support argument 0 of type tuple which "
f"has no callable {func.__name__} method"
)
with pytest.raises(expected_exception, match=msg):
func(idx)
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/indexes/period/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ def test_get_loc(self):
idx0.get_loc(1.1)

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

msg = (
r"'PeriodIndex\(\['2017-09-02', '2017-09-02', '2017-09-03'\],"
r" dtype='period\[D\]', freq='D'\)' is an invalid key"
r"'PeriodIndex\(\['2017-09-02', '2017-09-02', '2017-09-03'\], "
r"dtype='period\[D\]', freq='D'\)' is an invalid key"
)
with pytest.raises(TypeError, match=msg):
idx1.get_loc(idx1)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def test_constructor_invalid(self):

# invalid
msg = (
r"Float64Index\(\.\.\.\) must be called with a collection of"
r" some kind, 0\.0 was passed"
r"Float64Index\(\.\.\.\) must be called with a collection of "
r"some kind, 0\.0 was passed"
)
with pytest.raises(TypeError, match=msg):
Float64Index(0.0)
Expand Down
Loading