Skip to content

Commit ca70744

Browse files
authored
STY: enable PLR5501 (#56895)
1 parent 0d67ef9 commit ca70744

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

pandas/tests/copy_view/test_indexing.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -941,15 +941,14 @@ def test_column_as_series(backend, using_copy_on_write, warn_copy_on_write):
941941

942942
if using_copy_on_write:
943943
s[0] = 0
944+
elif warn_copy_on_write:
945+
with tm.assert_cow_warning():
946+
s[0] = 0
944947
else:
945-
if warn_copy_on_write:
946-
with tm.assert_cow_warning():
948+
warn = SettingWithCopyWarning if dtype_backend == "numpy" else None
949+
with pd.option_context("chained_assignment", "warn"):
950+
with tm.assert_produces_warning(warn):
947951
s[0] = 0
948-
else:
949-
warn = SettingWithCopyWarning if dtype_backend == "numpy" else None
950-
with pd.option_context("chained_assignment", "warn"):
951-
with tm.assert_produces_warning(warn):
952-
s[0] = 0
953952

954953
expected = Series([0, 2, 3], name="a")
955954
tm.assert_series_equal(s, expected)

pandas/tests/window/test_rolling.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1693,12 +1693,11 @@ def test_rolling_quantile_interpolation_options(quantile, interpolation, data):
16931693

16941694
if np.isnan(q1):
16951695
assert np.isnan(q2)
1696+
elif not IS64:
1697+
# Less precision on 32-bit
1698+
assert np.allclose([q1], [q2], rtol=1e-07, atol=0)
16961699
else:
1697-
if not IS64:
1698-
# Less precision on 32-bit
1699-
assert np.allclose([q1], [q2], rtol=1e-07, atol=0)
1700-
else:
1701-
assert q1 == q2
1700+
assert q1 == q2
17021701

17031702

17041703
def test_invalid_quantile_value():

pandas/util/_validators.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,8 @@ def validate_percentile(q: float | Iterable[float]) -> np.ndarray:
335335
if q_arr.ndim == 0:
336336
if not 0 <= q_arr <= 1:
337337
raise ValueError(msg)
338-
else:
339-
if not all(0 <= qs <= 1 for qs in q_arr):
340-
raise ValueError(msg)
338+
elif not all(0 <= qs <= 1 for qs in q_arr):
339+
raise ValueError(msg)
341340
return q_arr
342341

343342

pyproject.toml

-2
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,6 @@ ignore = [
337337
"PLR2004",
338338
# comparison-with-itself
339339
"PLR0124",
340-
# Consider `elif` instead of `else` then `if` to remove indentation level
341-
"PLR5501",
342340
# collection-literal-concatenation
343341
"RUF005",
344342
# pairwise-over-zipped (>=PY310 only)

0 commit comments

Comments
 (0)