From 9e11f71a3f8432ad7a70453cb0bf22513ce2d032 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Sun, 11 Aug 2024 22:32:20 +0200
Subject: [PATCH] Fix ruff C409 failures

---
 arraycontext/container/arithmetic.py |  5 ++---
 arraycontext/context.py              |  2 +-
 arraycontext/impl/pytato/compile.py  |  7 ++++---
 arraycontext/pytest.py               |  2 +-
 arraycontext/version.py              |  2 +-
 test/test_arraycontext.py            | 19 ++++++++-----------
 6 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/arraycontext/container/arithmetic.py b/arraycontext/container/arithmetic.py
index b085a7d..66e10ff 100644
--- a/arraycontext/container/arithmetic.py
+++ b/arraycontext/container/arithmetic.py
@@ -413,9 +413,8 @@ def with_container_arithmetic(
             for i, bct in enumerate(bcast_container_types):
                 gen(f"from {bct.__module__} import {bct.__qualname__} as _bctype{i}")
             gen("")
-        outer_bcast_type_names = tuple([
-                f"_bctype{i}" for i in range(len(bcast_container_types))
-                ])
+        outer_bcast_type_names = tuple(
+                f"_bctype{i}" for i in range(len(bcast_container_types)))
         if bcast_number:
             outer_bcast_type_names += ("Number",)
 
diff --git a/arraycontext/context.py b/arraycontext/context.py
index 3ccc357..d296f8f 100644
--- a/arraycontext/context.py
+++ b/arraycontext/context.py
@@ -475,7 +475,7 @@ class ArrayContext(ABC):
         :return: the output of the einsum :mod:`loopy` program
         """
         if arg_names is None:
-            arg_names = tuple([f"arg{i}" for i in range(len(args))])
+            arg_names = tuple(f"arg{i}" for i in range(len(args)))
 
         prg = self._get_einsum_prg(spec, arg_names, tagged)
         out_ary = self.call_loopy(
diff --git a/arraycontext/impl/pytato/compile.py b/arraycontext/impl/pytato/compile.py
index 523ef3a..54d2cbb 100644
--- a/arraycontext/impl/pytato/compile.py
+++ b/arraycontext/impl/pytato/compile.py
@@ -214,10 +214,10 @@ def _get_f_placeholder_args(arg, kw, arg_id_to_name, actx):
     :attr:`BaseLazilyCompilingFunctionCaller.f`.
     """
     if np.isscalar(arg):
-        name = arg_id_to_name[(kw,)]
+        name = arg_id_to_name[kw,]
         return pt.make_placeholder(name, (), np.dtype(type(arg)))
     elif isinstance(arg, pt.Array):
-        name = arg_id_to_name[(kw,)]
+        name = arg_id_to_name[kw,]
         # Transform the DAG to give metadata inference a chance to do its job
         arg = _to_input_for_compiled(arg, actx)
         return pt.make_placeholder(name, arg.shape, arg.dtype,
@@ -225,7 +225,8 @@ def _get_f_placeholder_args(arg, kw, arg_id_to_name, actx):
                                    tags=arg.tags)
     elif is_array_container_type(arg.__class__):
         def _rec_to_placeholder(keys, ary):
-            name = arg_id_to_name[(kw, *keys)]
+            index = (kw, *keys)
+            name = arg_id_to_name[index]
             # Transform the DAG to give metadata inference a chance to do its job
             ary = _to_input_for_compiled(ary, actx)
             return pt.make_placeholder(name,
diff --git a/arraycontext/pytest.py b/arraycontext/pytest.py
index e74a6ae..088c7e3 100644
--- a/arraycontext/pytest.py
+++ b/arraycontext/pytest.py
@@ -396,7 +396,7 @@ def pytest_generate_tests_for_array_contexts(
 
         # NOTE: sorts the args so that parallel pytest works
         arg_value_tuples = sorted([
-                tuple([arg_dict[name] for name in arg_names])
+                tuple(arg_dict[name] for name in arg_names)
                 for arg_dict in arg_values_with_actx
                 ], key=lambda x: str(x))
 
diff --git a/arraycontext/version.py b/arraycontext/version.py
index a1da82c..31baea0 100644
--- a/arraycontext/version.py
+++ b/arraycontext/version.py
@@ -8,7 +8,7 @@ def _parse_version(version: str) -> Tuple[Tuple[int, ...], str]:
     m = re.match("^([0-9.]+)([a-z0-9]*?)$", VERSION_TEXT)
     assert m is not None
 
-    return tuple([int(nr) for nr in m.group(1).split(".")]), m.group(2)
+    return tuple(int(nr) for nr in m.group(1).split(".")), m.group(2)
 
 
 VERSION_TEXT = metadata.version("arraycontext")
diff --git a/test/test_arraycontext.py b/test/test_arraycontext.py
index 63387db..107539b 100644
--- a/test/test_arraycontext.py
+++ b/test/test_arraycontext.py
@@ -170,11 +170,11 @@ class DOFArray:
 
     @property
     def real(self):
-        return DOFArray(self.array_context, tuple([subary.real for subary in self]))
+        return DOFArray(self.array_context, tuple(subary.real for subary in self))
 
     @property
     def imag(self):
-        return DOFArray(self.array_context, tuple([subary.imag for subary in self]))
+        return DOFArray(self.array_context, tuple(subary.imag for subary in self))
 
 
 @serialize_container.register(DOFArray)
@@ -258,9 +258,8 @@ def _get_test_containers(actx, ambient_dim=2, shapes=50_000):
     if isinstance(shapes, (Number, tuple)):
         shapes = [shapes]
 
-    x = DOFArray(actx, tuple([
-        actx.from_numpy(randn(shape, np.float64))
-        for shape in shapes]))
+    x = DOFArray(actx, tuple(actx.from_numpy(randn(shape, np.float64))
+        for shape in shapes))
 
     # pylint: disable=unexpected-keyword-arg, no-value-for-parameter
     dataclass_of_dofs = MyContainer(
@@ -1081,13 +1080,11 @@ def test_flatten_array_container(actx_factory, shapes):
     if isinstance(shapes, (int, tuple)):
         shapes = [shapes]
 
-    ary = DOFArray(actx, tuple([
-        actx.from_numpy(randn(shape, np.float64))
-        for shape in shapes]))
+    ary = DOFArray(actx, tuple(actx.from_numpy(randn(shape, np.float64))
+        for shape in shapes))
 
-    template = DOFArray(actx, tuple([
-        actx.from_numpy(randn(shape, np.complex128))
-        for shape in shapes]))
+    template = DOFArray(actx, tuple(actx.from_numpy(randn(shape, np.complex128))
+        for shape in shapes))
 
     flat = flatten(ary, actx)
     ary_roundtrip = unflatten(template, flat, actx, strict=False)
-- 
GitLab