diff --git a/pandas/core/computation/pytables.py b/pandas/core/computation/pytables.py index f0f3e7f19db50..bea3da589d86e 100644 --- a/pandas/core/computation/pytables.py +++ b/pandas/core/computation/pytables.py @@ -470,7 +470,7 @@ def visit_Attribute(self, node, **kwargs): # try to get the value to see if we are another expression try: resolved = resolved.value - except (AttributeError): + except AttributeError: pass try: diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index db3c86b734cf4..bf473f5ea428e 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -1723,7 +1723,7 @@ def _apply( f"Function {repr(func)} must return a DataFrame or ndarray " f"when passed to `Styler.apply` with axis=None" ) - if not (data.shape == result.shape): + if data.shape != result.shape: raise ValueError( f"Function {repr(func)} returned ndarray with wrong shape.\n" f"Result has shape: {result.shape}\n" @@ -3310,9 +3310,9 @@ def bar( "(eg: color=['#d65f5f', '#5fba7d'])" ) - if not (0 <= width <= 100): + if not 0 <= width <= 100: raise ValueError(f"`width` must be a value in [0, 100], got {width}") - elif not (0 <= height <= 100): + elif not 0 <= height <= 100: raise ValueError(f"`height` must be a value in [0, 100], got {height}") if subset is None: diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index a95d1b9d7cce6..30712ec1f0836 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -4945,7 +4945,7 @@ def _unconvert_index(data, kind: str, encoding: str, errors: str) -> np.ndarray elif kind == "date": try: index = np.asarray([date.fromordinal(v) for v in data], dtype=object) - except (ValueError): + except ValueError: index = np.asarray([date.fromtimestamp(v) for v in data], dtype=object) elif kind in ("integer", "float", "bool"): index = np.asarray(data) diff --git a/pandas/tests/groupby/test_allowlist.py b/pandas/tests/groupby/test_allowlist.py index 93df7d1f1d4a0..d75853159b21c 100644 --- a/pandas/tests/groupby/test_allowlist.py +++ b/pandas/tests/groupby/test_allowlist.py @@ -315,9 +315,9 @@ def test_all_methods_categorized(mframe): new_names -= transformation_kernels new_names -= groupby_other_methods - assert not (reduction_kernels & transformation_kernels) - assert not (reduction_kernels & groupby_other_methods) - assert not (transformation_kernels & groupby_other_methods) + assert not reduction_kernels & transformation_kernels + assert not reduction_kernels & groupby_other_methods + assert not transformation_kernels & groupby_other_methods # new public method? if new_names: @@ -341,7 +341,7 @@ def test_all_methods_categorized(mframe): all_categorized = reduction_kernels | transformation_kernels | groupby_other_methods print(names) print(all_categorized) - if not (names == all_categorized): + if names != all_categorized: msg = f""" Some methods which are supposed to be on the Grouper class are missing: diff --git a/pandas/tests/indexes/datetimelike.py b/pandas/tests/indexes/datetimelike.py index ecdbf01fd41c1..f836672cc8557 100644 --- a/pandas/tests/indexes/datetimelike.py +++ b/pandas/tests/indexes/datetimelike.py @@ -49,7 +49,7 @@ def test_str(self, simple_index): # test the string repr idx = simple_index idx.name = "foo" - assert not (f"length={len(idx)}" in str(idx)) + assert f"length={len(idx)}" not in str(idx) assert "'foo'" in str(idx) assert type(idx).__name__ in str(idx) diff --git a/pandas/tests/indexes/timedeltas/test_indexing.py b/pandas/tests/indexes/timedeltas/test_indexing.py index bdf299f6dbbdf..ff4b8564f86ca 100644 --- a/pandas/tests/indexes/timedeltas/test_indexing.py +++ b/pandas/tests/indexes/timedeltas/test_indexing.py @@ -374,7 +374,7 @@ def test_contains(self): # GH#13603 td = to_timedelta(range(5), unit="d") + offsets.Hour(1) for v in [NaT, None, float("nan"), np.nan]: - assert not (v in td) + assert v not in td td = to_timedelta([NaT]) for v in [NaT, None, float("nan"), np.nan]: diff --git a/pandas/tests/io/formats/style/test_style.py b/pandas/tests/io/formats/style/test_style.py index 192fec048a930..77a996b1f92d6 100644 --- a/pandas/tests/io/formats/style/test_style.py +++ b/pandas/tests/io/formats/style/test_style.py @@ -352,7 +352,7 @@ def test_clear(mi_styler_comp): # test vars have same vales on obj and clean copy after clearing styler.clear() - for attr in [a for a in styler.__dict__ if not (callable(a))]: + for attr in [a for a in styler.__dict__ if not callable(a)]: res = getattr(styler, attr) == getattr(clean_copy, attr) assert all(res) if hasattr(res, "__iter__") else res diff --git a/pandas/tests/io/formats/test_format.py b/pandas/tests/io/formats/test_format.py index a2f2dce70c7f4..0b3f6395e51d7 100644 --- a/pandas/tests/io/formats/test_format.py +++ b/pandas/tests/io/formats/test_format.py @@ -985,7 +985,7 @@ def test_to_string_truncate_indices(self, index, h, w): if w == 20: assert has_horizontally_truncated_repr(df) else: - assert not (has_horizontally_truncated_repr(df)) + assert not has_horizontally_truncated_repr(df) with option_context("display.max_rows", 15, "display.max_columns", 15): if h == 20 and w == 20: assert has_doubly_truncated_repr(df) diff --git a/pandas/tests/io/generate_legacy_storage_files.py b/pandas/tests/io/generate_legacy_storage_files.py index 8f03655ec27cc..b66631a7d943e 100644 --- a/pandas/tests/io/generate_legacy_storage_files.py +++ b/pandas/tests/io/generate_legacy_storage_files.py @@ -326,7 +326,7 @@ def write_legacy_file(): # force our cwd to be the first searched sys.path.insert(0, ".") - if not (3 <= len(sys.argv) <= 4): + if not 3 <= len(sys.argv) <= 4: exit( "Specify output directory and storage type: generate_legacy_" "storage_files.py " diff --git a/pandas/tests/scalar/timedelta/test_arithmetic.py b/pandas/tests/scalar/timedelta/test_arithmetic.py index f5cfc6fecb5d0..72ee89a4b5108 100644 --- a/pandas/tests/scalar/timedelta/test_arithmetic.py +++ b/pandas/tests/scalar/timedelta/test_arithmetic.py @@ -1055,13 +1055,13 @@ def __gt__(self, other): t = Timedelta("1s") - assert not (t == "string") - assert not (t == 1) - assert not (t == CustomClass()) - assert not (t == CustomClass(cmp_result=False)) + assert t != "string" + assert t != 1 + assert t != CustomClass() + assert t != CustomClass(cmp_result=False) assert t < CustomClass(cmp_result=True) - assert not (t < CustomClass(cmp_result=False)) + assert not t < CustomClass(cmp_result=False) assert t == CustomClass(cmp_result=True) diff --git a/pandas/tests/scalar/timestamp/test_comparisons.py b/pandas/tests/scalar/timestamp/test_comparisons.py index 510c29bd3893d..2c9b029bf109e 100644 --- a/pandas/tests/scalar/timestamp/test_comparisons.py +++ b/pandas/tests/scalar/timestamp/test_comparisons.py @@ -324,5 +324,5 @@ def __eq__(self, other) -> bool: for left, right in [(inf, timestamp), (timestamp, inf)]: assert left > right or left < right assert left >= right or left <= right - assert not (left == right) + assert not left == right assert left != right diff --git a/pandas/tests/series/methods/test_reindex.py b/pandas/tests/series/methods/test_reindex.py index b64c7bec6ea39..60ada18410415 100644 --- a/pandas/tests/series/methods/test_reindex.py +++ b/pandas/tests/series/methods/test_reindex.py @@ -55,7 +55,7 @@ def test_reindex(datetime_series, string_series): # return a copy the same index here result = datetime_series.reindex() - assert not (result is datetime_series) + assert result is not datetime_series def test_reindex_nan(): diff --git a/pandas/tests/tseries/offsets/test_ticks.py b/pandas/tests/tseries/offsets/test_ticks.py index 7a174b89baa9b..7e7f6dc86b8f9 100644 --- a/pandas/tests/tseries/offsets/test_ticks.py +++ b/pandas/tests/tseries/offsets/test_ticks.py @@ -90,11 +90,10 @@ def test_tick_equality(cls, n, m): left = cls(n) right = cls(m) assert left != right - assert not (left == right) right = cls(n) assert left == right - assert not (left != right) + assert not left != right if n != 0: assert cls(n) != cls(-n) diff --git a/pyproject.toml b/pyproject.toml index b8568f1839f42..10e6a2bfe8436 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,7 +91,6 @@ disable = [ "missing-function-docstring", "missing-module-docstring", "singleton-comparison", - "superfluous-parens", "too-many-lines", "typevar-name-incorrect-variance", "ungrouped-imports", @@ -139,7 +138,6 @@ disable = [ "too-many-branches", "too-many-instance-attributes", "too-many-locals", - "too-many-locals", "too-many-nested-blocks", "too-many-public-methods", "too-many-return-statements",