Skip to content

STYLE enable pylint: chained-comparison #49586

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 1 commit into from
Nov 9, 2022
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
2 changes: 1 addition & 1 deletion pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ def compute(self, method: str) -> Series:
inds = inds[:n]
findex = nbase
else:
if len(inds) < nbase and len(nan_index) + len(inds) >= nbase:
if len(inds) < nbase <= len(nan_index) + len(inds):
findex = len(nan_index) + len(inds)
else:
findex = len(inds)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ def _generate_range_overflow_safe(
return _generate_range_overflow_safe_signed(endpoint, periods, stride, side)

elif (endpoint > 0 and side == "start" and stride > 0) or (
endpoint < 0 and side == "end" and stride > 0
endpoint < 0 < stride and side == "end"
):
# no chance of not-overflowing
raise OutOfBoundsDatetime(msg)

elif side == "end" and endpoint > i64max and endpoint - stride <= i64max:
elif side == "end" and endpoint - stride <= i64max < endpoint:
# in _generate_regular_range we added `stride` thereby overflowing
# the bounds. Adjust to fix this.
return _generate_range_overflow_safe(
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def range_to_ndarray(rng: range) -> np.ndarray:
arr = np.arange(rng.start, rng.stop, rng.step, dtype="int64")
except OverflowError:
# GH#30173 handling for ranges that overflow int64
if (rng.start >= 0 and rng.step > 0) or (rng.stop >= 0 and rng.step < 0):
if (rng.start >= 0 and rng.step > 0) or (rng.step < 0 <= rng.stop):
try:
arr = np.arange(rng.start, rng.stop, rng.step, dtype="uint64")
except OverflowError:
Expand Down
4 changes: 2 additions & 2 deletions pandas/plotting/_matplotlib/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def normalize(series):
ax.text(
xy[0] - 0.025, xy[1] - 0.025, name, ha="right", va="top", size="small"
)
elif xy[0] < 0.0 and xy[1] >= 0.0:
elif xy[0] < 0.0 <= xy[1]:
ax.text(
xy[0] - 0.025,
xy[1] + 0.025,
Expand All @@ -210,7 +210,7 @@ def normalize(series):
va="bottom",
size="small",
)
elif xy[0] >= 0.0 and xy[1] < 0.0:
elif xy[1] < 0.0 <= xy[0]:
ax.text(
xy[0] + 0.025, xy[1] - 0.025, name, ha="left", va="top", size="small"
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/formats/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_info_verbose_check_header_separator_body():
assert len(lines) > 0

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

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ disable = [
"wrong-import-position",

# pylint type "R": refactor, for bad code smell
"chained-comparison",
"comparison-with-itself",
"consider-merging-isinstance",
"consider-using-ternary",
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,9 @@ def run(self):
target_macos_version = "10.9"
parsed_macos_version = parse_version(target_macos_version)
if (
parse_version(str(python_target)) < parsed_macos_version
and parse_version(current_system) >= parsed_macos_version
parse_version(str(python_target))
< parsed_macos_version
<= parse_version(current_system)
):
os.environ["MACOSX_DEPLOYMENT_TARGET"] = target_macos_version

Expand Down