From 9d4111e1afd85c1d89fdc1c0bccf43b88bf171fd Mon Sep 17 00:00:00 2001 From: soumil Date: Sat, 1 Oct 2022 01:03:21 +0530 Subject: [PATCH 1/4] fix pylint bad-super-call --- pandas/tests/extension/json/test_json.py | 2 +- pandas/tests/extension/test_sparse.py | 2 +- pandas/tests/generic/test_frame.py | 14 +++++++------- pyproject.toml | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index f3129a89124f4..b8df787b7214a 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -159,7 +159,7 @@ class TestConstructors(BaseJSON, base.BaseConstructorsTests): @pytest.mark.xfail(reason="not implemented constructor from dtype") def test_from_dtype(self, data): # construct from our dtype & string dtype - super(self).test_from_dtype(data) + super().test_from_dtype(data) @pytest.mark.xfail(reason="RecursionError, GH-33900") def test_series_constructor_no_data_with_index(self, dtype, na_value): diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 0a2686a24c732..86a523404ef8b 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -268,7 +268,7 @@ def test_fillna_series_method(self, data_missing): @pytest.mark.xfail(reason="Unsupported") def test_fillna_series(self): # this one looks doable. - super(self).test_fillna_series() + super().test_fillna_series() def test_fillna_frame(self, data_missing): # Have to override to specify that fill_value will change. diff --git a/pandas/tests/generic/test_frame.py b/pandas/tests/generic/test_frame.py index b4a3a60e72139..ff7b828b507b2 100644 --- a/pandas/tests/generic/test_frame.py +++ b/pandas/tests/generic/test_frame.py @@ -157,27 +157,27 @@ def test_validate_bool_args(self, value): msg = 'For argument "inplace" expected type bool, received type' with pytest.raises(ValueError, match=msg): - super(DataFrame, df).rename_axis( + super().rename_axis( mapper={"a": "x", "b": "y"}, axis=1, inplace=value ) with pytest.raises(ValueError, match=msg): - super(DataFrame, df).drop("a", axis=1, inplace=value) + super().drop("a", axis=1, inplace=value) with pytest.raises(ValueError, match=msg): - super(DataFrame, df).fillna(value=0, inplace=value) + super().fillna(value=0, inplace=value) with pytest.raises(ValueError, match=msg): - super(DataFrame, df).replace(to_replace=1, value=7, inplace=value) + super().replace(to_replace=1, value=7, inplace=value) with pytest.raises(ValueError, match=msg): - super(DataFrame, df).interpolate(inplace=value) + super().interpolate(inplace=value) with pytest.raises(ValueError, match=msg): - super(DataFrame, df)._where(cond=df.a > 2, inplace=value) + super()._where(cond=df.a > 2, inplace=value) with pytest.raises(ValueError, match=msg): - super(DataFrame, df).mask(cond=df.a > 2, inplace=value) + super().mask(cond=df.a > 2, inplace=value) def test_unexpected_keyword(self): # GH8597 diff --git a/pyproject.toml b/pyproject.toml index 3e87d237170aa..dcdb2911dd410 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ disable = [ "W", "abstract-class-instantiated", "access-member-before-definition", - "bad-super-call", + "c-extension-no-member", "function-redefined", "import-error", From ca138932d0afda5440e8b4f60977cc4bea370014 Mon Sep 17 00:00:00 2001 From: soumil Date: Sat, 1 Oct 2022 01:26:59 +0530 Subject: [PATCH 2/4] fix black pre commit --- pandas/tests/generic/test_frame.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/tests/generic/test_frame.py b/pandas/tests/generic/test_frame.py index ff7b828b507b2..22c5cc1cad347 100644 --- a/pandas/tests/generic/test_frame.py +++ b/pandas/tests/generic/test_frame.py @@ -157,9 +157,7 @@ def test_validate_bool_args(self, value): msg = 'For argument "inplace" expected type bool, received type' with pytest.raises(ValueError, match=msg): - super().rename_axis( - mapper={"a": "x", "b": "y"}, axis=1, inplace=value - ) + super().rename_axis(mapper={"a": "x", "b": "y"}, axis=1, inplace=value) with pytest.raises(ValueError, match=msg): super().drop("a", axis=1, inplace=value) From 30aedf6a998e89bd87448abdffd85b219405dc9f Mon Sep 17 00:00:00 2001 From: soumilbaldota <71919921+soumilbaldota@users.noreply.github.com> Date: Wed, 5 Oct 2022 14:59:16 +0530 Subject: [PATCH 3/4] Update pyproject.toml Co-authored-by: Marco Edward Gorelli <33491632+MarcoGorelli@users.noreply.github.com> --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index dcdb2911dd410..779020a5b36c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ disable = [ "W", "abstract-class-instantiated", "access-member-before-definition", - "c-extension-no-member", "function-redefined", "import-error", From 05f141c7ae25b5dcd18d2a74c2554ae4417a27f7 Mon Sep 17 00:00:00 2001 From: soumil Date: Wed, 5 Oct 2022 15:13:26 +0530 Subject: [PATCH 4/4] change super() to df.copy() --- pandas/tests/generic/test_frame.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandas/tests/generic/test_frame.py b/pandas/tests/generic/test_frame.py index 22c5cc1cad347..c72e8158a0725 100644 --- a/pandas/tests/generic/test_frame.py +++ b/pandas/tests/generic/test_frame.py @@ -157,25 +157,25 @@ def test_validate_bool_args(self, value): msg = 'For argument "inplace" expected type bool, received type' with pytest.raises(ValueError, match=msg): - super().rename_axis(mapper={"a": "x", "b": "y"}, axis=1, inplace=value) + df.copy().rename_axis(mapper={"a": "x", "b": "y"}, axis=1, inplace=value) with pytest.raises(ValueError, match=msg): - super().drop("a", axis=1, inplace=value) + df.copy().drop("a", axis=1, inplace=value) with pytest.raises(ValueError, match=msg): - super().fillna(value=0, inplace=value) + df.copy().fillna(value=0, inplace=value) with pytest.raises(ValueError, match=msg): - super().replace(to_replace=1, value=7, inplace=value) + df.copy().replace(to_replace=1, value=7, inplace=value) with pytest.raises(ValueError, match=msg): - super().interpolate(inplace=value) + df.copy().interpolate(inplace=value) with pytest.raises(ValueError, match=msg): - super()._where(cond=df.a > 2, inplace=value) + df.copy()._where(cond=df.a > 2, inplace=value) with pytest.raises(ValueError, match=msg): - super().mask(cond=df.a > 2, inplace=value) + df.copy().mask(cond=df.a > 2, inplace=value) def test_unexpected_keyword(self): # GH8597