Skip to content

Commit d443106

Browse files
DimitriPapadopoulosmattip
authored andcommitted
Apply ruff/pycodestyle rule E711
E711 Comparison to `None` should be `cond is not None`
1 parent ccfd16f commit d443106

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

src/c/test_c.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def test_reading_pointer_to_pointer():
460460
assert p[0] is not None
461461
assert p[0] == cast(BVoidP, 0)
462462
assert p[0] == cast(BCharP, 0)
463-
assert p[0] != None
463+
assert p[0] is not None
464464
assert repr(p[0]) == "<cdata 'int *' NULL>"
465465
p[0] = q
466466
assert p[0] != cast(BVoidP, 0)
@@ -495,12 +495,12 @@ def test_no_len_on_nonarray():
495495
def test_cmp_none():
496496
p = new_primitive_type("int")
497497
x = cast(p, 42)
498-
assert (x == None) is False
499-
assert (x != None) is True
498+
assert (x is None) is False
499+
assert (x is not None) is True
500500
assert (x == ["hello"]) is False
501501
assert (x != ["hello"]) is True
502502
y = cast(p, 0)
503-
assert (y == None) is False
503+
assert (y is None) is False
504504

505505
def test_invalid_indexing():
506506
p = new_primitive_type("int")

testing/cffi0/backend_tests.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_pointer_direct(self):
207207
assert p is not None
208208
assert bool(p) is False
209209
assert p == ffi.cast("int*", 0)
210-
assert p != None
210+
assert p is not None
211211
assert repr(p) == "<cdata 'int *' NULL>"
212212
a = ffi.new("int[]", [123, 456])
213213
p = ffi.cast("int*", a)
@@ -397,7 +397,7 @@ def test_none_as_null_doesnt_work(self):
397397
ffi = FFI(backend=self.Backend())
398398
p = ffi.new("int*[1]")
399399
assert p[0] is not None
400-
assert p[0] != None
400+
assert p[0] is not None
401401
assert p[0] == ffi.NULL
402402
assert repr(p[0]) == "<cdata 'int *' NULL>"
403403
#
@@ -1154,14 +1154,14 @@ def test_pointer_comparison(self):
11541154
assert (p > q) is False
11551155
assert (p >= q) is False
11561156
#
1157-
assert (None == s) is False
1158-
assert (None != s) is True
1159-
assert (s == None) is False
1160-
assert (s != None) is True
1161-
assert (None == q) is False
1162-
assert (None != q) is True
1163-
assert (q == None) is False
1164-
assert (q != None) is True
1157+
assert (None is s) is False
1158+
assert (None is not s) is True
1159+
assert (s is None) is False
1160+
assert (s is not None) is True
1161+
assert (None is q) is False
1162+
assert (None is not q) is True
1163+
assert (q is None) is False
1164+
assert (q is not None) is True
11651165

11661166
def test_integer_comparison(self):
11671167
ffi = FFI(backend=self.Backend())

testing/cffi1/test_new_ffi_1.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def test_pointer_direct(self):
265265
assert p is not None
266266
assert bool(p) is False
267267
assert p == ffi.cast("int*", 0)
268-
assert p != None
268+
assert p is not None
269269
assert repr(p) == "<cdata 'int *' NULL>"
270270
a = ffi.new("int[]", [123, 456])
271271
p = ffi.cast("int*", a)
@@ -446,7 +446,7 @@ def test_wchar_t(self):
446446
def test_none_as_null_doesnt_work(self):
447447
p = ffi.new("int*[1]")
448448
assert p[0] is not None
449-
assert p[0] != None
449+
assert p[0] is not None
450450
assert p[0] == ffi.NULL
451451
assert repr(p[0]) == "<cdata 'int *' NULL>"
452452
#
@@ -1130,14 +1130,14 @@ def test_pointer_comparison(self):
11301130
assert (p > q) is False
11311131
assert (p >= q) is False
11321132
#
1133-
assert (None == s) is False
1134-
assert (None != s) is True
1135-
assert (s == None) is False
1136-
assert (s != None) is True
1137-
assert (None == q) is False
1138-
assert (None != q) is True
1139-
assert (q == None) is False
1140-
assert (q != None) is True
1133+
assert (None is s) is False
1134+
assert (None is not s) is True
1135+
assert (s is None) is False
1136+
assert (s is not None) is True
1137+
assert (None is q) is False
1138+
assert (None is not q) is True
1139+
assert (q is None) is False
1140+
assert (q is not None) is True
11411141

11421142
def test_integer_comparison(self):
11431143
x = ffi.cast("int", 123)

testing/cffi1/test_zdist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def run(self, args, cwd=None):
4343
# NOTE: pointing $HOME to a nonexistent directory can break certain things
4444
# that look there for configuration (like ccache).
4545
tmp_home = mkdtemp()
46-
assert tmp_home != None, "cannot create temporary homedir"
46+
assert tmp_home is not None, "cannot create temporary homedir"
4747
env['HOME'] = tmp_home
4848
pathlist = sys.path[:]
4949
if cwd is None:

0 commit comments

Comments
 (0)