Skip to content

Commit 694c0cd

Browse files
authored
STYLE: fix pylint unneeded-not warnings (#49382)
* STYLE: fix pylint unneeded-not warnings * fixup! STYLE: fix pylint unneeded-not warnings * Add __ne__ method to ArrowPeriodType and ArrowIntervalType * fixup! Add __ne__ method to ArrowPeriodType and ArrowIntervalType
1 parent f6d3cb2 commit 694c0cd

File tree

8 files changed

+14
-9
lines changed

8 files changed

+14
-9
lines changed

pandas/core/arrays/arrow/extension_types.py

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def __eq__(self, other):
3535
else:
3636
return NotImplemented
3737

38+
def __ne__(self, other) -> bool:
39+
return not self == other
40+
3841
def __hash__(self) -> int:
3942
return hash((str(self), self.freq))
4043

@@ -91,6 +94,9 @@ def __eq__(self, other):
9194
else:
9295
return NotImplemented
9396

97+
def __ne__(self, other) -> bool:
98+
return not self == other
99+
94100
def __hash__(self) -> int:
95101
return hash((str(self), str(self.subtype), self.closed))
96102

pandas/io/formats/style_render.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(
9898
self.data: DataFrame = data
9999
self.index: Index = data.index
100100
self.columns: Index = data.columns
101-
if not isinstance(uuid_len, int) or not uuid_len >= 0:
101+
if not isinstance(uuid_len, int) or uuid_len < 0:
102102
raise TypeError("``uuid_len`` must be an integer in range [0, 32].")
103103
self.uuid = uuid or uuid4().hex[: min(32, uuid_len)]
104104
self.uuid_len = len(self.uuid)

pandas/tests/arrays/interval/test_interval.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ def test_arrow_extension_type():
256256

257257
assert p1.closed == "left"
258258
assert p1 == p2
259-
assert not p1 == p3
259+
assert p1 != p3
260260
assert hash(p1) == hash(p2)
261-
assert not hash(p1) == hash(p3)
261+
assert hash(p1) != hash(p3)
262262

263263

264264
@pyarrow_skip

pandas/tests/arrays/period/test_arrow_compat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def test_arrow_extension_type():
2121

2222
assert p1.freq == "D"
2323
assert p1 == p2
24-
assert not p1 == p3
24+
assert p1 != p3
2525
assert hash(p1) == hash(p2)
26-
assert not hash(p1) == hash(p3)
26+
assert hash(p1) != hash(p3)
2727

2828

2929
@pytest.mark.parametrize(

pandas/tests/indexes/multi/test_indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ def test_contains_td64_level(self):
810810
def test_large_mi_contains(self):
811811
# GH#10645
812812
result = MultiIndex.from_arrays([range(10**6), range(10**6)])
813-
assert not (10**6, 0) in result
813+
assert (10**6, 0) not in result
814814

815815

816816
def test_timestamp_multiindex_indexer():

pandas/tests/scalar/timedelta/test_arithmetic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1114,5 +1114,5 @@ def test_ops_error_str():
11141114
with pytest.raises(TypeError, match=msg):
11151115
left > right
11161116

1117-
assert not left == right
1117+
assert not left == right # pylint: disable=unneeded-not
11181118
assert left != right

pandas/tests/scalar/timestamp/test_comparisons.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,5 +310,5 @@ def __eq__(self, other) -> bool:
310310
for left, right in [(inf, timestamp), (timestamp, inf)]:
311311
assert left > right or left < right
312312
assert left >= right or left <= right
313-
assert not left == right
313+
assert not left == right # pylint: disable=unneeded-not
314314
assert left != right

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ disable = [
9090
"unidiomatic-typecheck",
9191
"unnecessary-dunder-call",
9292
"unnecessary-lambda-assignment",
93-
"unneeded-not",
9493
"use-implicit-booleaness-not-comparison",
9594
"use-implicit-booleaness-not-len",
9695
"wrong-import-order",

0 commit comments

Comments
 (0)