Skip to content

Commit fd45dcc

Browse files
authored
fix(mlir/**.py): fix comparison to None (#94019)
from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations): > Comparisons to singletons like None should always be done with is or is not, never the equality operators. Co-authored-by: Eisuke Kawashima <[email protected]>
1 parent af3ffff commit fd45dcc

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

mlir/test/python/ir/affine_expr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def testAffineExprEq():
4242
# CHECK: False
4343
print(a1 == a3)
4444
# CHECK: False
45-
print(a1 == None)
45+
print(a1 is None)
4646
# CHECK: False
4747
print(a1 == "foo")
4848

mlir/test/python/ir/attributes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def testAttrEq():
5656
print("a1 == a2:", a1 == a2)
5757
# CHECK: a1 == a3: True
5858
print("a1 == a3:", a1 == a3)
59-
# CHECK: a1 == None: False
60-
print("a1 == None:", a1 == None)
59+
# CHECK: a1 is None: False
60+
print("a1 is None:", a1 is None)
6161

6262

6363
# CHECK-LABEL: TEST: testAttrHash
@@ -109,9 +109,9 @@ def testAttrEqDoesNotRaise():
109109
# CHECK: False
110110
print(a1 == not_an_attr)
111111
# CHECK: False
112-
print(a1 == None)
112+
print(a1 is None)
113113
# CHECK: True
114-
print(a1 != None)
114+
print(a1 is not None)
115115

116116

117117
# CHECK-LABEL: TEST: testAttrCapsule

mlir/test/python/ir/builtin_types.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def testTypeEq():
5757
print("t1 == t2:", t1 == t2)
5858
# CHECK: t1 == t3: True
5959
print("t1 == t3:", t1 == t3)
60-
# CHECK: t1 == None: False
61-
print("t1 == None:", t1 == None)
60+
# CHECK: t1 is None: False
61+
print("t1 is None:", t1 is None)
6262

6363

6464
# CHECK-LABEL: TEST: testTypeHash
@@ -143,9 +143,9 @@ def testTypeEqDoesNotRaise():
143143
# CHECK: False
144144
print(t1 == not_a_type)
145145
# CHECK: False
146-
print(t1 == None)
146+
print(t1 is None)
147147
# CHECK: True
148-
print(t1 != None)
148+
print(t1 is not None)
149149

150150

151151
# CHECK-LABEL: TEST: testTypeCapsule

0 commit comments

Comments
 (0)