From c276919f868fb59359f2a489eca7ad62947dfa39 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Wed, 17 Jul 2024 13:56:35 -0500
Subject: [PATCH] Enable RUF and UP rules

---
 benchmarks/bench_translations.py  | 18 +++++++-------
 examples/expansion-toys.py        |  2 +-
 pyproject.toml                    |  4 ++--
 sumpy/__init__.py                 | 19 ++++++++++-----
 sumpy/cse.py                      |  2 +-
 sumpy/e2e.py                      | 39 ++++++++++++++++++-------------
 sumpy/e2p.py                      | 14 +++++------
 sumpy/expansion/__init__.py       |  2 +-
 sumpy/expansion/diff_op.py        |  4 ++--
 sumpy/expansion/level_to_order.py |  2 +-
 sumpy/expansion/local.py          |  3 +--
 sumpy/expansion/loopy.py          |  4 ++--
 sumpy/fmm.py                      |  2 +-
 sumpy/kernel.py                   | 12 +++++-----
 sumpy/p2e.py                      |  2 +-
 sumpy/p2p.py                      | 11 ++++-----
 sumpy/qbx.py                      |  7 +++---
 sumpy/symbolic.py                 |  4 ++--
 sumpy/tools.py                    |  3 ++-
 sumpy/toys.py                     |  4 ++--
 test/test_cse.py                  | 10 ++++----
 21 files changed, 91 insertions(+), 77 deletions(-)

diff --git a/benchmarks/bench_translations.py b/benchmarks/bench_translations.py
index 8c31eb8b..0601889c 100644
--- a/benchmarks/bench_translations.py
+++ b/benchmarks/bench_translations.py
@@ -33,15 +33,15 @@ class Param:
 
 class TranslationBenchmarkSuite:
 
-    params = [
+    params = (
         Param(2, 10),
         Param(2, 15),
         Param(2, 20),
         Param(3, 5),
         Param(3, 10),
-    ]
+    )
 
-    param_names = ["order"]
+    param_names = ("order",)
 
     def setup(self, param):
         logging.basicConfig(level=logging.INFO)
@@ -88,10 +88,10 @@ class LaplaceVolumeTaylorTranslation(TranslationBenchmarkSuite):
     knl = LaplaceKernel
     local_expn_class = VolumeTaylorLocalExpansion
     mpole_expn_class = VolumeTaylorMultipoleExpansion
-    params = [
+    params = (
         Param(2, 10),
         Param(3, 5),
-    ]
+    )
 
 
 class LaplaceConformingVolumeTaylorTranslation(TranslationBenchmarkSuite):
@@ -104,10 +104,10 @@ class HelmholtzVolumeTaylorTranslation(TranslationBenchmarkSuite):
     knl = HelmholtzKernel
     local_expn_class = VolumeTaylorLocalExpansion
     mpole_expn_class = VolumeTaylorMultipoleExpansion
-    params = [
+    params = (
         Param(2, 10),
         Param(3, 5),
-    ]
+    )
 
 
 class HelmholtzConformingVolumeTaylorTranslation(TranslationBenchmarkSuite):
@@ -120,8 +120,8 @@ class Helmholtz2DTranslation(TranslationBenchmarkSuite):
     knl = HelmholtzKernel
     local_expn_class = H2DLocalExpansion
     mpole_expn_class = H2DMultipoleExpansion
-    params = [
+    params = (
         Param(2, 10),
         Param(2, 15),
         Param(2, 20),
-    ]
+    )
diff --git a/examples/expansion-toys.py b/examples/expansion-toys.py
index 6e7d66b3..e76e958d 100644
--- a/examples/expansion-toys.py
+++ b/examples/expansion-toys.py
@@ -43,7 +43,7 @@ def main():
         plt.show()
 
     mexp = t.multipole_expand(pt_src, [0, 0], 5)
-    mexp2 = t.multipole_expand(mexp, [0, 0.25])  # noqa: F841
+    mexp2 = t.multipole_expand(mexp, [0, 0.25])
     lexp = t.local_expand(mexp, [3, 0])
     lexp2 = t.local_expand(lexp, [3, 1], 3)
 
diff --git a/pyproject.toml b/pyproject.toml
index 11cf370c..19db2276 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -13,8 +13,8 @@ extend-select = [
     "N",   # pep8-naming
     "NPY", # numpy
     "Q",   # flake8-quotes
-    # "UP",  # pyupgrade
-    # "RUF", # ruff
+    "UP",  # pyupgrade
+    "RUF", # ruff
     # "W",   # pycodestyle
 ]
 extend-ignore = [
diff --git a/sumpy/__init__.py b/sumpy/__init__.py
index d03122e1..e4daaaae 100644
--- a/sumpy/__init__.py
+++ b/sumpy/__init__.py
@@ -32,13 +32,20 @@ from sumpy.version import VERSION_TEXT
 from pytools.persistent_dict import WriteOncePersistentDict
 
 __all__ = [
-    "P2P", "P2PFromCSR",
-    "P2EFromSingleBox", "P2EFromCSR",
-    "E2PFromSingleBox", "E2PFromCSR",
-    "E2EFromCSR", "E2EFromChildren", "E2EFromParent",
-    "M2LUsingTranslationClassesDependentData",
+    "P2P",
+    "E2EFromCSR",
+    "E2EFromChildren",
+    "E2EFromParent",
+    "E2PFromCSR",
+    "E2PFromSingleBox",
     "M2LGenerateTranslationClassesDependentData",
-    "M2LPreprocessMultipole", "M2LPostprocessLocal"]
+    "M2LPostprocessLocal",
+    "M2LPreprocessMultipole",
+    "M2LUsingTranslationClassesDependentData",
+    "P2EFromCSR",
+    "P2EFromSingleBox",
+    "P2PFromCSR",
+]
 
 
 code_cache = WriteOncePersistentDict("sumpy-code-cache-v6-"+VERSION_TEXT,
diff --git a/sumpy/cse.py b/sumpy/cse.py
index 635c26f1..c401e84f 100644
--- a/sumpy/cse.py
+++ b/sumpy/cse.py
@@ -304,7 +304,7 @@ def match_common_args(func_class, funcs, opt_subs):
         # This makes us try combining smaller matches first.
         common_arg_candidates = OrderedSet(sorted(
                 common_arg_candidates_counts.keys(),
-                key=lambda k: (common_arg_candidates_counts[k], k)))  # noqa: B023
+                key=lambda k: (common_arg_candidates_counts[k], k)))
 
         while common_arg_candidates:
             j = common_arg_candidates.pop(last=False)
diff --git a/sumpy/e2e.py b/sumpy/e2e.py
index c66f9c02..4167d993 100644
--- a/sumpy/e2e.py
+++ b/sumpy/e2e.py
@@ -257,9 +257,10 @@ class E2EFromCSR(E2EBase):
                         shape=("nsrc_level_boxes", ncoeff_src), offset=lp.auto),
                     lp.GlobalArg("tgt_expansions", None,
                         shape=("ntgt_level_boxes", ncoeff_tgt), offset=lp.auto),
-                    "..."
-                ] + gather_loopy_arguments([self.src_expansion,
-                                            self.tgt_expansion]),
+                    "...",
+                    *gather_loopy_arguments([self.src_expansion,
+                                            self.tgt_expansion])
+                ],
                 name=self.name,
                 assumptions="ntgt_boxes>=1",
                 silenced_warnings="write_race(write_expn*)",
@@ -489,9 +490,10 @@ class M2LUsingTranslationClassesDependentData(E2EFromCSR):
                         offset=lp.auto),
                     lp.ValueArg("ntranslation_classes, ntranslation_classes_lists",
                         np.int32),
-                    ...
-                ] + gather_loopy_arguments([self.src_expansion,
-                                            self.tgt_expansion]),
+                    ...,
+                    *gather_loopy_arguments([self.src_expansion,
+                                            self.tgt_expansion])
+                ],
                 name=self.name,
                 assumptions="ntgt_boxes>=1",
                 default_offset=lp.auto,
@@ -600,8 +602,9 @@ class M2LGenerateTranslationClassesDependentData(E2EBase):
                     lp.ValueArg("ntranslation_classes", np.int32),
                     lp.ValueArg("ntranslation_vectors", np.int32),
                     lp.ValueArg("translation_classes_level_start", np.int32),
-                    "..."
-                ] + gather_loopy_arguments([self.src_expansion, self.tgt_expansion]),
+                    "...",
+                    *gather_loopy_arguments([self.src_expansion, self.tgt_expansion])
+                ],
                 name=self.name,
                 assumptions="ntranslation_classes>=1",
                 default_offset=lp.auto,
@@ -712,8 +715,9 @@ class M2LPreprocessMultipole(E2EBase):
                     lp.GlobalArg("preprocessed_src_expansions", None,
                         shape=("nsrc_boxes", npreprocessed_src_coeffs),
                         offset=lp.auto),
-                    "..."
-                ] + gather_loopy_arguments([self.src_expansion, self.tgt_expansion]),
+                    "...",
+                    *gather_loopy_arguments([self.src_expansion, self.tgt_expansion])
+                ],
                 name=self.name,
                 assumptions="nsrc_boxes>=1",
                 fixed_parameters={
@@ -807,8 +811,9 @@ class M2LPostprocessLocal(E2EBase):
                     lp.GlobalArg("tgt_expansions_before_postprocessing", None,
                         shape=("ntgt_boxes", ntgt_coeffs_before_postprocessing),
                         offset=lp.auto),
-                    "..."
-                ] + gather_loopy_arguments([self.src_expansion, self.tgt_expansion]),
+                    "...",
+                    *gather_loopy_arguments([self.src_expansion, self.tgt_expansion])
+                ],
                 name=self.name,
                 assumptions="ntgt_boxes>=1",
                 default_offset=lp.auto,
@@ -931,8 +936,9 @@ class E2EFromChildren(E2EBase):
                     lp.ValueArg("src_base_ibox,tgt_base_ibox", np.int32),
                     lp.ValueArg("ntgt_level_boxes,nsrc_level_boxes", np.int32),
                     lp.ValueArg("aligned_nboxes", np.int32),
-                    "..."
-                ] + gather_loopy_arguments([self.src_expansion, self.tgt_expansion]),
+                    "...",
+                    *gather_loopy_arguments([self.src_expansion, self.tgt_expansion])
+                ],
                 name=self.name,
                 assumptions="ntgt_boxes>=1",
                 silenced_warnings="write_race(write_expn*)",
@@ -1036,8 +1042,9 @@ class E2EFromParent(E2EBase):
                         shape=("ntgt_level_boxes", ncoeffs_tgt), offset=lp.auto),
                     lp.GlobalArg("src_expansions", None,
                         shape=("nsrc_level_boxes", ncoeffs_src), offset=lp.auto),
-                    "..."
-                ] + gather_loopy_arguments([self.src_expansion, self.tgt_expansion]),
+                    "...",
+                    *gather_loopy_arguments([self.src_expansion, self.tgt_expansion])
+                ],
                 name=self.name, assumptions="ntgt_boxes>=1",
                 silenced_warnings="write_race(write_expn*)",
                 fixed_parameters={"dim": self.dim, "nchildren": 2**self.dim},
diff --git a/sumpy/e2p.py b/sumpy/e2p.py
index 55af69b3..f19ca7d7 100644
--- a/sumpy/e2p.py
+++ b/sumpy/e2p.py
@@ -97,7 +97,7 @@ class E2PBase(KernelCacheMixin, ABC):
         return loopy_knl
 
     def get_loopy_args(self):
-        return gather_loopy_arguments((self.expansion,) + tuple(self.kernels))
+        return gather_loopy_arguments((self.expansion, *tuple(self.kernels)))
 
     def get_kernel_scaling_assignment(self):
         from sumpy.symbolic import SympyToPymbolicMapper
@@ -128,9 +128,9 @@ class E2PFromSingleBox(E2PBase):
                     "{[itgt,idim]: itgt_start<=itgt<itgt_end and 0<=idim<dim}",
                     "{[icoeff]: 0<=icoeff<ncoeffs}",
                     "{[iknl]: 0<=iknl<nresults}",
-                ],
-                self.get_kernel_scaling_assignment()
-                + ["""
+                ], [
+                *self.get_kernel_scaling_assignment(),
+                """
                 for itgt_box
                     <> tgt_ibox = target_boxes[itgt_box]
                     <> itgt_start = box_target_starts[tgt_ibox]
@@ -243,9 +243,9 @@ class E2PFromCSR(E2PBase):
                     "{[idim]: 0<=idim<dim}",
                     "{[icoeff]: 0<=icoeff<ncoeffs}",
                     "{[iknl]: 0<=iknl<nresults}",
-                ],
-                self.get_kernel_scaling_assignment()
-                + ["""
+                ], [
+                *self.get_kernel_scaling_assignment(),
+                """
                 for itgt_box
                     <> tgt_ibox = target_boxes[itgt_box]
                     <> itgt_start = box_target_starts[tgt_ibox]
diff --git a/sumpy/expansion/__init__.py b/sumpy/expansion/__init__.py
index 493ff710..294337dc 100644
--- a/sumpy/expansion/__init__.py
+++ b/sumpy/expansion/__init__.py
@@ -419,7 +419,7 @@ class FullExpansionTermsWrangler(ExpansionTermsWrangler):
                 mi = ident.mi
             else:
                 mi = ident
-            return tuple([sum(mi)] + list(reversed(mi)))
+            return (sum(mi), *list(reversed(mi)))
 
         return mi_key, axis_permutation
 # }}}
diff --git a/sumpy/expansion/diff_op.py b/sumpy/expansion/diff_op.py
index 8d8700ba..bca672c7 100644
--- a/sumpy/expansion/diff_op.py
+++ b/sumpy/expansion/diff_op.py
@@ -122,7 +122,7 @@ class LinearPDESystemOperator:
         return self + (-1)*other_diff_op
 
     def __repr__(self):
-        return f"LinearPDESystemOperator({self.dim}, {repr(self.eqs)})"
+        return f"LinearPDESystemOperator({self.dim}, {self.eqs!r})"
 
     def __getitem__(self, idx):
         item = self.eqs.__getitem__(idx)
@@ -313,7 +313,7 @@ def as_scalar_pde(pde: LinearPDESystemOperator, comp_idx: int) \
             indices.add(deriv_ident.vec_idx)
 
     # this is already a scalar pde
-    if len(indices) == 1 and list(indices)[0] == comp_idx:
+    if len(indices) == 1 and next(iter(indices)) == comp_idx:
         return pde
 
     return _get_all_scalar_pdes(pde)[comp_idx]
diff --git a/sumpy/expansion/level_to_order.py b/sumpy/expansion/level_to_order.py
index 82db1aef..9c9f1310 100644
--- a/sumpy/expansion/level_to_order.py
+++ b/sumpy/expansion/level_to_order.py
@@ -133,7 +133,7 @@ class SimpleExpansionOrderFinder:
 
         laplace_order = int(np.ceil(
                 (np.log(self.tol) - np.log(self.err_const_laplace))
-                /  # noqa: W504
+                /
                 np.log(
                     np.sqrt(tree.dimensions)/3
                     ) - 1))
diff --git a/sumpy/expansion/local.py b/sumpy/expansion/local.py
index 7f0607f0..13933d73 100644
--- a/sumpy/expansion/local.py
+++ b/sumpy/expansion/local.py
@@ -340,8 +340,7 @@ class VolumeTaylorLocalExpansionBase(VolumeTaylorExpansionMixin, LocalExpansionB
         for axis in {d for d, _ in tgt_split}:
             # Use the axis as the first dimension to vary so that the below
             # algorithm is O(p^{d+1}) for full and O(p^{d}) for compressed
-            dims = [axis] + list(range(axis)) + \
-                    list(range(axis+1, self.dim))
+            dims = [axis, *list(range(axis)), *list(range(axis + 1, self.dim))]
             # Start with source coefficients. Gets updated after each axis.
             cur_dim_input_coeffs = src_coeffs
             # O(1) iterations
diff --git a/sumpy/expansion/loopy.py b/sumpy/expansion/loopy.py
index 00bbd3db..20be150a 100644
--- a/sumpy/expansion/loopy.py
+++ b/sumpy/expansion/loopy.py
@@ -64,7 +64,7 @@ def make_e2p_loopy_kernel(
             expression="target[idim]-center[idim]",
             temp_var_type=lp.Optional(None),
         ))
-    target_args = gather_loopy_arguments((expansion,) + tuple(kernels))
+    target_args = gather_loopy_arguments((expansion, *tuple(kernels)))
 
     coeff_exprs = sym.make_sym_vector("coeffs", ncoeffs)
     coeff_names = [
@@ -159,7 +159,7 @@ def make_p2e_loopy_kernel(
             expression="center[idim]-source[idim]",
             temp_var_type=lp.Optional(None),
         ))
-    source_args = gather_loopy_source_arguments((expansion,) + tuple(kernels))
+    source_args = gather_loopy_source_arguments((expansion, *tuple(kernels)))
 
     all_strengths = sym.make_sym_vector("strength", nstrengths)
     strengths = [all_strengths[i] for i in strength_usage]
diff --git a/sumpy/fmm.py b/sumpy/fmm.py
index de7ac6ae..d956c100 100644
--- a/sumpy/fmm.py
+++ b/sumpy/fmm.py
@@ -28,7 +28,7 @@ __doc__ = """Integrates :mod:`boxtree` with :mod:`sumpy`.
 
 
 import pyopencl as cl
-import pyopencl.array  # noqa
+import pyopencl.array
 
 from pytools import memoize_method
 from boxtree.fmm import TreeIndependentDataForWrangler, ExpansionWranglerInterface
diff --git a/sumpy/kernel.py b/sumpy/kernel.py
index d3edefa0..0c68aa15 100644
--- a/sumpy/kernel.py
+++ b/sumpy/kernel.py
@@ -160,7 +160,7 @@ class Kernel:
         try:
             return self.hash_value
         except AttributeError:
-            self.hash_value = hash((type(self),) + self.__getinitargs__())
+            self.hash_value = hash((type(self), *self.__getinitargs__()))
             return self.hash_value
 
     def update_persistent_hash(self, key_hash, key_builder):
@@ -692,7 +692,7 @@ class ElasticityKernel(ExpressionKernel):
             # See (Berger and Karageorghis 2001)
             expr = (
                 -var("log")(r)*((3 - 4 * nu) if icomp == jcomp else 0)
-                +  # noqa: W504
+                +
                 d[icomp]*d[jcomp]/r**2
                 )
             scaling = -1/(8*var("pi")*(1 - nu)*mu)
@@ -703,7 +703,7 @@ class ElasticityKernel(ExpressionKernel):
             # Kelvin solution
             expr = (
                 (1/r)*((3 - 4*nu) if icomp == jcomp else 0)
-                +  # noqa: W504
+                +
                 d[icomp]*d[jcomp]/r**3
                 )
             scaling = -1/(16*var("pi")*(1 - nu)*mu)
@@ -1081,7 +1081,7 @@ class _VectorIndexAdder(CSECachingMapperMixin, IdentityMapper):
         if expr.aggregate.name == self.vec_name \
                 and isinstance(expr.index, int):
             return CommonSubexpression(
-                    expr.aggregate.index((expr.index,) + self.additional_indices),
+                    expr.aggregate.index((expr.index, *self.additional_indices)),
                     prefix=None, scope=cse_scope.EVALUATION)
         else:
             return IdentityMapper.map_subscript(self, expr)
@@ -1231,8 +1231,8 @@ class DirectionalSourceDerivative(DirectionalDerivative):
                         None,
                         shape=(self.dim, "nsources"),
                         offset=lp.auto),
-                    )
-                    ] + self.inner_kernel.get_source_args()
+                    ),
+                    *self.inner_kernel.get_source_args()]
 
     def prepare_loopy_kernel(self, loopy_knl):
         loopy_knl = self.inner_kernel.prepare_loopy_kernel(loopy_knl)
diff --git a/sumpy/p2e.py b/sumpy/p2e.py
index acc7e726..7268275c 100644
--- a/sumpy/p2e.py
+++ b/sumpy/p2e.py
@@ -102,7 +102,7 @@ class P2EBase(KernelCacheMixin, KernelComputation):
     def get_loopy_args(self):
         from sumpy.tools import gather_loopy_source_arguments
         return gather_loopy_source_arguments(
-                (self.expansion,) + tuple(self.source_kernels))
+                (self.expansion, *tuple(self.source_kernels)))
 
     def get_cache_key(self):
         return (type(self).__name__, self.name, self.expansion,
diff --git a/sumpy/p2p.py b/sumpy/p2p.py
index 6babc237..ed3e8012 100644
--- a/sumpy/p2p.py
+++ b/sumpy/p2p.py
@@ -210,14 +210,13 @@ class P2P(P2PBase):
 
     def get_kernel(self):
         loopy_insns, result_names = self.get_loopy_insns_and_result_names()
-        arguments = (
-            self.get_default_src_tgt_arguments()
-            + [
+        arguments = [
+                *self.get_default_src_tgt_arguments(),
                 lp.GlobalArg("strength", None,
                     shape="nstrengths, nsources", dim_tags="sep,C"),
                 lp.GlobalArg("result", None,
                     shape="nresults, ntargets", dim_tags="sep,C")
-            ])
+            ]
 
         loopy_knl = lp.make_kernel(["""
             {[itgt, isrc, idim]: \
@@ -454,8 +453,8 @@ class P2PFromCSR(P2PBase):
     def get_kernel(self, max_nsources_in_one_box, max_ntargets_in_one_box,
             work_items_per_group=32):
         loopy_insns, result_names = self.get_loopy_insns_and_result_names()
-        arguments = self.get_default_src_tgt_arguments() \
-            + [
+        arguments = [
+                *self.get_default_src_tgt_arguments(),
                 lp.GlobalArg("box_target_starts",
                     None, shape=None),
                 lp.GlobalArg("box_target_counts_nonchild",
diff --git a/sumpy/qbx.py b/sumpy/qbx.py
index 19ff0f7f..345d251a 100644
--- a/sumpy/qbx.py
+++ b/sumpy/qbx.py
@@ -168,7 +168,7 @@ class LayerPotentialBase(KernelCacheMixin, KernelComputation):
 
     def get_default_src_tgt_arguments(self):
         from sumpy.tools import gather_loopy_source_arguments
-        return ([
+        return [
                 lp.GlobalArg("sources", None,
                     shape=(self.dim, "nsources"), order="C"),
                 lp.GlobalArg("targets", None,
@@ -178,8 +178,9 @@ class LayerPotentialBase(KernelCacheMixin, KernelComputation):
                 lp.GlobalArg("expansion_radii",
                     None, shape="ntargets"),
                 lp.ValueArg("nsources", None),
-                lp.ValueArg("ntargets", None)]
-                + gather_loopy_source_arguments(self.source_kernels))
+                lp.ValueArg("ntargets", None),
+                *gather_loopy_source_arguments(self.source_kernels)
+            ]
 
     def get_kernel(self):
         raise NotImplementedError
diff --git a/sumpy/symbolic.py b/sumpy/symbolic.py
index 48d43a5e..089b1507 100644
--- a/sumpy/symbolic.py
+++ b/sumpy/symbolic.py
@@ -129,13 +129,13 @@ def _coeff_isneg(a):
 
 
 if USE_SYMENGINE:
-    def UnevaluatedExpr(x):  # noqa: F811, N802
+    def UnevaluatedExpr(x):  # noqa: N802
         return x
 else:
     try:
         from sympy import UnevaluatedExpr
     except ImportError:
-        def UnevaluatedExpr(x):  # noqa: F811, N802
+        def UnevaluatedExpr(x):  # noqa: N802
             return x
 
 
diff --git a/sumpy/tools.py b/sumpy/tools.py
index 8c666b61..6b8b6882 100644
--- a/sumpy/tools.py
+++ b/sumpy/tools.py
@@ -955,7 +955,8 @@ def run_opencl_fft(
         queue: "pyopencl.CommandQueue",
         input_vec: Any,
         inverse: bool = False,
-        wait_for: List["pyopencl.Event"] = None) -> Tuple["pyopencl.Event", Any]:
+        wait_for: Optional[List["pyopencl.Event"]] = None
+    ) -> Tuple["pyopencl.Event", Any]:
     """Runs an FFT on input_vec and returns a :class:`MarkerBasedProfilingEvent`
     that indicate the end and start of the operations carried out and the output
     vector.
diff --git a/sumpy/toys.py b/sumpy/toys.py
index 41117eed..45d71425 100644
--- a/sumpy/toys.py
+++ b/sumpy/toys.py
@@ -35,9 +35,9 @@ from sumpy.kernel import TargetTransformationRemover
 if TYPE_CHECKING:
     from sumpy.kernel import Kernel
     from sumpy.visualization import FieldPlotter
-    import pyopencl  # noqa: F401
+    import pyopencl
 
-import numpy as np  # noqa: F401
+import numpy as np
 import loopy as lp  # noqa: F401
 import pyopencl as cl
 import pyopencl.array
diff --git a/test/test_cse.py b/test/test_cse.py
index e84548c7..e8840788 100644
--- a/test/test_cse.py
+++ b/test/test_cse.py
@@ -142,8 +142,8 @@ def test_cse_not_possible():
     assert substs == []
     assert reduced == [x + y]
     # issue 6329
-    eq = (meijerg((1, 2), (y, 4), (5,), [], x)  # pylint: disable=possibly-used-before-assignment  # noqa: E501
-          + meijerg((1, 3), (y, 4), (5,), [], x))  # pylint: disable=possibly-used-before-assignment  # noqa: E501
+    eq = (meijerg((1, 2), (y, 4), (5,), [], x)  # pylint: disable=possibly-used-before-assignment
+          + meijerg((1, 3), (y, 4), (5,), [], x))  # pylint: disable=possibly-used-before-assignment
     assert cse(eq) == ([], [eq])
 
 # }}}
@@ -168,7 +168,7 @@ def test_subtraction_opt():
     # Make sure subtraction is optimized.
     e = (x - y)*(z - y) + sym.exp((x - y)*(z - y))
     substs, reduced = cse(
-        [e], optimizations=[(cse_opts.sub_pre, cse_opts.sub_post)])  # pylint: disable=possibly-used-before-assignment  # noqa: E501
+        [e], optimizations=[(cse_opts.sub_pre, cse_opts.sub_post)])  # pylint: disable=possibly-used-before-assignment
     assert substs == [(x0, (x - y)*(y - z))]
     assert reduced == [-x0 + sym.exp(-x0)]
     e = -(x - y)*(z - y) + sym.exp(-(x - y)*(z - y))
@@ -180,7 +180,7 @@ def test_subtraction_opt():
     n = -1 + 1/x
     e = n/x/(-n)**2 - 1/n/x
     assert cse(e, optimizations=[
-               (cse_opts.sub_pre, cse_opts.sub_post)]  # pylint: disable=possibly-used-before-assignment  # noqa: E501
+               (cse_opts.sub_pre, cse_opts.sub_post)]  # pylint: disable=possibly-used-before-assignment
                ) == ([], [0])
 
 # }}}
@@ -332,7 +332,7 @@ def test_issue_6169():
     assert cse(r) == ([], [r])
     # and a check that the right thing is done with the new
     # mechanism
-    assert sub_post(sub_pre((-x - y)*z - x - y)) == -z*(x + y) - x - y  # pylint: disable=possibly-used-before-assignment  # noqa: E501
+    assert sub_post(sub_pre((-x - y)*z - x - y)) == -z*(x + y) - x - y  # pylint: disable=possibly-used-before-assignment
 
 # }}}
 
-- 
GitLab