diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 7494a8a54f9bb..1e112b61d0e62 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -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) diff --git a/pandas/core/arrays/_ranges.py b/pandas/core/arrays/_ranges.py index 3bef3e59d5687..f50ce8a9ea895 100644 --- a/pandas/core/arrays/_ranges.py +++ b/pandas/core/arrays/_ranges.py @@ -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( diff --git a/pandas/core/construction.py b/pandas/core/construction.py index 997611d7860db..8fc77d47554dd 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -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: diff --git a/pandas/plotting/_matplotlib/misc.py b/pandas/plotting/_matplotlib/misc.py index 2f482c7d86571..9c054b5f03198 100644 --- a/pandas/plotting/_matplotlib/misc.py +++ b/pandas/plotting/_matplotlib/misc.py @@ -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, @@ -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" ) diff --git a/pandas/tests/io/formats/test_info.py b/pandas/tests/io/formats/test_info.py index 54b5e699cd034..33c78baa1eedc 100644 --- a/pandas/tests/io/formats/test_info.py +++ b/pandas/tests/io/formats/test_info.py @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 55d20f4e1eaa0..de91edd62f457 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/setup.py b/setup.py index f0a81779a90b6..05d4407c7e959 100755 --- a/setup.py +++ b/setup.py @@ -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