Skip to content

Commit d56f6e2

Browse files
authored
STYLE enable pylint: chained-comparison (#49586)
1 parent e7a5c92 commit d56f6e2

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

pandas/core/algorithms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ def compute(self, method: str) -> Series:
12471247
inds = inds[:n]
12481248
findex = nbase
12491249
else:
1250-
if len(inds) < nbase and len(nan_index) + len(inds) >= nbase:
1250+
if len(inds) < nbase <= len(nan_index) + len(inds):
12511251
findex = len(nan_index) + len(inds)
12521252
else:
12531253
findex = len(inds)

pandas/core/arrays/_ranges.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ def _generate_range_overflow_safe(
121121
return _generate_range_overflow_safe_signed(endpoint, periods, stride, side)
122122

123123
elif (endpoint > 0 and side == "start" and stride > 0) or (
124-
endpoint < 0 and side == "end" and stride > 0
124+
endpoint < 0 < stride and side == "end"
125125
):
126126
# no chance of not-overflowing
127127
raise OutOfBoundsDatetime(msg)
128128

129-
elif side == "end" and endpoint > i64max and endpoint - stride <= i64max:
129+
elif side == "end" and endpoint - stride <= i64max < endpoint:
130130
# in _generate_regular_range we added `stride` thereby overflowing
131131
# the bounds. Adjust to fix this.
132132
return _generate_range_overflow_safe(

pandas/core/construction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ def range_to_ndarray(rng: range) -> np.ndarray:
666666
arr = np.arange(rng.start, rng.stop, rng.step, dtype="int64")
667667
except OverflowError:
668668
# GH#30173 handling for ranges that overflow int64
669-
if (rng.start >= 0 and rng.step > 0) or (rng.stop >= 0 and rng.step < 0):
669+
if (rng.start >= 0 and rng.step > 0) or (rng.step < 0 <= rng.stop):
670670
try:
671671
arr = np.arange(rng.start, rng.stop, rng.step, dtype="uint64")
672672
except OverflowError:

pandas/plotting/_matplotlib/misc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def normalize(series):
201201
ax.text(
202202
xy[0] - 0.025, xy[1] - 0.025, name, ha="right", va="top", size="small"
203203
)
204-
elif xy[0] < 0.0 and xy[1] >= 0.0:
204+
elif xy[0] < 0.0 <= xy[1]:
205205
ax.text(
206206
xy[0] - 0.025,
207207
xy[1] + 0.025,
@@ -210,7 +210,7 @@ def normalize(series):
210210
va="bottom",
211211
size="small",
212212
)
213-
elif xy[0] >= 0.0 and xy[1] < 0.0:
213+
elif xy[1] < 0.0 <= xy[0]:
214214
ax.text(
215215
xy[0] + 0.025, xy[1] - 0.025, name, ha="left", va="top", size="small"
216216
)

pandas/tests/io/formats/test_info.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_info_verbose_check_header_separator_body():
116116
assert len(lines) > 0
117117

118118
for i, line in enumerate(lines):
119-
if i >= start and i < start + size:
119+
if start <= i < start + size:
120120
line_nr = f" {i - start} "
121121
assert line.startswith(line_nr)
122122

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ disable = [
100100
"wrong-import-position",
101101

102102
# pylint type "R": refactor, for bad code smell
103-
"chained-comparison",
104103
"comparison-with-itself",
105104
"consider-merging-isinstance",
106105
"consider-using-ternary",

setup.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,9 @@ def run(self):
355355
target_macos_version = "10.9"
356356
parsed_macos_version = parse_version(target_macos_version)
357357
if (
358-
parse_version(str(python_target)) < parsed_macos_version
359-
and parse_version(current_system) >= parsed_macos_version
358+
parse_version(str(python_target))
359+
< parsed_macos_version
360+
<= parse_version(current_system)
360361
):
361362
os.environ["MACOSX_DEPLOYMENT_TARGET"] = target_macos_version
362363

0 commit comments

Comments
 (0)