intel/genxml: don't use parens with python assert statement
authorDylan Baker <dylan.c.baker@intel.com>
Fri, 30 Sep 2022 18:00:57 +0000 (11:00 -0700)
committerDylan Baker <dylan.c.baker@intel.com>
Sat, 1 Oct 2022 21:03:49 +0000 (14:03 -0700)
assert is a statement in python, not a function. Useing parens with it
leads to madness, because assert takes two arguments in the form `assert
expression: bool, message: str`. With parens though it's tempting to
write `assert(expression, message)`, which results in an assert that is
*always* true, because a non-empty tuple (which is what is written) is
*never* false.

Reviewd-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18917>

src/intel/genxml/gen_sort_tags.py

index cab59f9..c8b524b 100755 (executable)
@@ -60,7 +60,7 @@ class Struct(object):
             if d in struct_dict:
                 self.deps[d] = struct_dict[d]
             else:
-                assert(d in enum_dict)
+                assert d in enum_dict
 
     def add_xml(self, items):
         for d in self.deps.values():
@@ -89,7 +89,7 @@ def print_node(f, offset, node):
     f.write('{0}<{1}'.format(spaces, node.tag))
     attribs = genxml_desc[node.tag]
     for a in node.attrib:
-        assert(a in attribs)
+        assert a in attribs 
     for a in attribs:
         if a in node.attrib:
             f.write(' {0}="{1}"'.format(a, node.attrib[a]))