This is an automated email from the ASF dual-hosted git repository.
ruihangl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 0fdb2cd84d fix: use `is None` instead of `== None` in test files (PEP
8 E711) (#19393)
0fdb2cd84d is described below
commit 0fdb2cd84d5de0592a5c509c9d8850bc3c60eb00
Author: harshadkhetpal <[email protected]>
AuthorDate: Fri Apr 17 07:22:23 2026 +0530
fix: use `is None` instead of `== None` in test files (PEP 8 E711) (#19393)
Replace `== None` and `!= None` comparisons with `is None` and `is not
None` in test files, per PEP 8 (E711).
Python's `is` operator is the recommended way to compare with singletons
like `None`, as it checks identity rather than equality. Using `==` can
produce unexpected results if `__eq__` is overridden.
---------
Co-authored-by: Ruihang Lai <[email protected]>
---
tests/python/ir/test_ir_type.py | 2 +-
tests/python/tirx-base/test_tir_base.py | 4 ++++
tests/python/tirx-base/test_tir_constructor.py | 2 +-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/python/ir/test_ir_type.py b/tests/python/ir/test_ir_type.py
index 8fee003b76..339a92f435 100644
--- a/tests/python/ir/test_ir_type.py
+++ b/tests/python/ir/test_ir_type.py
@@ -39,7 +39,7 @@ def test_func_type():
tf = tvm.ir.FuncType(arg_types, ret_type)
assert tf.arg_types == arg_types
assert tf.ret_type == ret_type
- assert tf.span == None
+ assert tf.span is None
# TODO make sure we can set span
str(tf)
check_json_roundtrip(tf)
diff --git a/tests/python/tirx-base/test_tir_base.py
b/tests/python/tirx-base/test_tir_base.py
index 7607e96399..f799ef2a14 100644
--- a/tests/python/tirx-base/test_tir_base.py
+++ b/tests/python/tirx-base/test_tir_base.py
@@ -176,6 +176,10 @@ def test_exception():
def test_eq_ops():
+ # NOTE: the `== None` / `!= None` below are intentional and must NOT be
+ # rewritten as `is None` / `is not None`. This test exercises the
overloaded
+ # `__eq__` / `__ne__` operators on `IntImm` / `StringImm`; the `is`
operators
+ # bypass those overloads and would defeat the test.
a = tirx.IntImm("int8", 1)
with pytest.raises(ValueError):
assert a != None
diff --git a/tests/python/tirx-base/test_tir_constructor.py
b/tests/python/tirx-base/test_tir_constructor.py
index f8a30c7589..358091f8cd 100644
--- a/tests/python/tirx-base/test_tir_constructor.py
+++ b/tests/python/tirx-base/test_tir_constructor.py
@@ -29,7 +29,7 @@ def test_expr_constructor():
x = tvm.tirx.Reduce(None, [1], [tvm.tirx.IterVar((0, 1), "x", 2)], None, 0)
assert isinstance(x, tvm.tirx.Reduce)
- assert x.combiner == None
+ assert x.combiner is None
assert x.value_index == 0
x = tvm.tirx.FloatImm("float32", 1.0)