From f43d3a77d284adca8daddcb705ede1907de48eb6 Mon Sep 17 00:00:00 2001 From: Thierry Moisan Date: Wed, 2 Nov 2022 14:06:34 -0400 Subject: [PATCH] STYLE: fix pylint no-else-continue warnings (#49464) --- doc/source/conf.py | 2 +- pandas/core/indexes/multi.py | 8 ++++---- pandas/core/reshape/merge.py | 6 +++--- pandas/io/formats/style_render.py | 10 +++++----- pandas/io/json/_normalize.py | 6 +++--- pandas/tests/io/parser/common/test_common_basic.py | 4 ++-- pyproject.toml | 1 - 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 39acc28451f54..af93a979789c1 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -105,7 +105,7 @@ if fname == "index.rst" and os.path.abspath(dirname) == source_path: continue - elif pattern == "-api" and reldir.startswith("reference"): + if pattern == "-api" and reldir.startswith("reference"): exclude_patterns.append(fname) elif ( pattern == "whatsnew" diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 02edb8b971305..20c1760a2705e 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -3049,10 +3049,10 @@ def maybe_mi_droplevels(indexer, levels): ): # everything continue - else: - # e.g. test_xs_IndexSlice_argument_not_implemented - k_index = np.zeros(len(self), dtype=bool) - k_index[loc_level] = True + + # e.g. test_xs_IndexSlice_argument_not_implemented + k_index = np.zeros(len(self), dtype=bool) + k_index[loc_level] = True else: k_index = loc_level diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index f4332f2c7eb1b..7d9842f7e5341 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -1290,7 +1290,7 @@ def _maybe_coerce_merge_keys(self) -> None: continue # check whether ints and floats - elif is_integer_dtype(rk.dtype) and is_float_dtype(lk.dtype): + if is_integer_dtype(rk.dtype) and is_float_dtype(lk.dtype): # GH 47391 numpy > 1.24 will raise a RuntimeError for nan -> int with np.errstate(invalid="ignore"): # error: Argument 1 to "astype" of "ndarray" has incompatible @@ -1312,7 +1312,7 @@ def _maybe_coerce_merge_keys(self) -> None: ) continue - elif is_float_dtype(rk.dtype) and is_integer_dtype(lk.dtype): + if is_float_dtype(rk.dtype) and is_integer_dtype(lk.dtype): # GH 47391 numpy > 1.24 will raise a RuntimeError for nan -> int with np.errstate(invalid="ignore"): # error: Argument 1 to "astype" of "ndarray" has incompatible @@ -1335,7 +1335,7 @@ def _maybe_coerce_merge_keys(self) -> None: continue # let's infer and see if we are ok - elif lib.infer_dtype(lk, skipna=False) == lib.infer_dtype( + if lib.infer_dtype(lk, skipna=False) == lib.infer_dtype( rk, skipna=False ): continue diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 035c5d88a7f4b..06e5702896f2f 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -399,11 +399,11 @@ def _translate_header(self, sparsify_cols: bool, max_cols: int): for r, hide in enumerate(self.hide_columns_): if hide or not clabels: continue - else: - header_row = self._generate_col_header_row( - (r, clabels), max_cols, col_lengths - ) - head.append(header_row) + + header_row = self._generate_col_header_row( + (r, clabels), max_cols, col_lengths + ) + head.append(header_row) # 2) index names if ( diff --git a/pandas/io/json/_normalize.py b/pandas/io/json/_normalize.py index 03afdcda35021..7ed7ce18e355b 100644 --- a/pandas/io/json/_normalize.py +++ b/pandas/io/json/_normalize.py @@ -112,9 +112,9 @@ def nested_to_record( v = new_d.pop(k) new_d[newkey] = v continue - else: - v = new_d.pop(k) - new_d.update(nested_to_record(v, newkey, sep, level + 1, max_level)) + + v = new_d.pop(k) + new_d.update(nested_to_record(v, newkey, sep, level + 1, max_level)) new_ds.append(new_d) if singleton: diff --git a/pandas/tests/io/parser/common/test_common_basic.py b/pandas/tests/io/parser/common/test_common_basic.py index af7ebc5e9555c..8997fc83eb5cf 100644 --- a/pandas/tests/io/parser/common/test_common_basic.py +++ b/pandas/tests/io/parser/common/test_common_basic.py @@ -661,8 +661,8 @@ def test_read_table_same_signature_as_read_csv(all_parsers): assert table_param.annotation == csv_param.annotation assert table_param.kind == csv_param.kind continue - else: - assert table_param == csv_param + + assert table_param == csv_param def test_read_table_equivalency_to_read_csv(all_parsers): diff --git a/pyproject.toml b/pyproject.toml index e936ee6b55b1c..761f3c687d08d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,7 +113,6 @@ disable = [ "cyclic-import", "duplicate-code", "inconsistent-return-statements", - "no-else-continue", "no-else-raise", "no-else-return", "redefined-argument-from-local",