Skip to content

Fix code triggering superfluous-parens pylint messages #49219

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 3 commits into from
Oct 24, 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/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/groupby/test_allowlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/timedeltas/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/formats/style/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/generate_legacy_storage_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <output_dir> <storage_type> "
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/scalar/timedelta/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/scalar/timestamp/test_comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pandas/tests/series/methods/test_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/tseries/offsets/test_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ disable = [
"missing-function-docstring",
"missing-module-docstring",
"singleton-comparison",
"superfluous-parens",
"too-many-lines",
"typevar-name-incorrect-variance",
"ungrouped-imports",
Expand Down Expand Up @@ -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",
Expand Down