From c8b7ce9721c2c63250d949231fd444742a62d2e0 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 28 Aug 2026 16:42:07 -0500 Subject: [PATCH 1/2] Placate ruff 0.16.5 --- contrib/fortran-to-opencl/translate.py | 2 +- pyopencl/characterize/__init__.py | 10 ++-------- pyopencl/elementwise.py | 3 +-- pyopencl/invoker.py | 19 ++++++++----------- pyopencl/tools.py | 14 ++++---------- pyproject.toml | 1 + test/test_array.py | 2 +- test/test_wrapper.py | 4 ++-- 8 files changed, 20 insertions(+), 35 deletions(-) diff --git a/contrib/fortran-to-opencl/translate.py b/contrib/fortran-to-opencl/translate.py index a42ac5d9b..3bbbadd31 100644 --- a/contrib/fortran-to-opencl/translate.py +++ b/contrib/fortran-to-opencl/translate.py @@ -1263,7 +1263,7 @@ def end_block(): (current_cond, cgen.block_if_necessary( self.map_statement_list(current_body)))) - del current_body[:] + current_body.clear() from fparser.statements import Else, ElseIf i = 0 diff --git a/pyopencl/characterize/__init__.py b/pyopencl/characterize/__init__.py index 7d7895dae..5c28f2354 100644 --- a/pyopencl/characterize/__init__.py +++ b/pyopencl/characterize/__init__.py @@ -35,19 +35,13 @@ class CLCharacterizationWarning(UserWarning): @memoize def has_double_support(dev: cl.Device): - for ext in dev.extensions.split(" "): - if ext == "cl_khr_fp64": - return True - return False + return any(ext == "cl_khr_fp64" for ext in dev.extensions.split(" ")) def has_amd_double_support(dev: cl.Device): """"Fix to allow incomplete amd double support in low end boards""" - for ext in dev.extensions.split(" "): - if ext == "cl_amd_fp64": - return True - return False + return any(ext == "cl_amd_fp64" for ext in dev.extensions.split(" ")) def reasonable_work_group_size_multiple( diff --git a/pyopencl/elementwise.py b/pyopencl/elementwise.py index e31e6d1c3..61fd2d929 100644 --- a/pyopencl/elementwise.py +++ b/pyopencl/elementwise.py @@ -341,8 +341,7 @@ def __call__(self, start = range.start if start is None: start = 0 - invocation_args.append(start) - invocation_args.append(range.stop) + invocation_args.extend((start, range.stop)) if range.step is None: step = 1 else: diff --git a/pyopencl/invoker.py b/pyopencl/invoker.py index 9f26b3f14..c322365ac 100644 --- a/pyopencl/invoker.py +++ b/pyopencl/invoker.py @@ -65,8 +65,7 @@ def generate_generic_arg_handling_body(num_args): else: gen_indices_and_args = [] for i in range(num_args): - gen_indices_and_args.append(i) - gen_indices_and_args.append(f"arg{i}") + gen_indices_and_args.extend((i, f"arg{i}")) gen(f"self._set_arg_multi(" f"({', '.join(str(i) for i in gen_indices_and_args)},), " @@ -116,8 +115,7 @@ def add_buf_arg(arg_idx, typechar, expr_str): arg_var = "arg%d" % arg_idx if arg_type is None: - gen_indices_and_args.append(cl_arg_idx) - gen_indices_and_args.append(arg_var) + gen_indices_and_args.extend((cl_arg_idx, arg_var)) cl_arg_idx += 1 gen("") continue @@ -135,8 +133,7 @@ def add_buf_arg(arg_idx, typechar, expr_str): "'queues for all arrays must match the queue supplied " "to enqueue'") - gen_indices_and_args.append(cl_arg_idx) - gen_indices_and_args.append(f"{arg_var}.base_data") + gen_indices_and_args.extend((cl_arg_idx, f"{arg_var}.base_data")) cl_arg_idx += 1 if arg_type.with_offset: @@ -151,8 +148,7 @@ def add_buf_arg(arg_idx, typechar, expr_str): arg_dtype = np.dtype(arg_type) if arg_dtype.char == "V": - buf_indices_and_args.append(cl_arg_idx) - buf_indices_and_args.append(arg_var) + buf_indices_and_args.extend((cl_arg_idx, arg_var)) cl_arg_idx += 1 elif arg_dtype.kind == "c": @@ -187,9 +183,10 @@ def add_buf_arg(arg_idx, typechar, expr_str): "Cannot pass complex numbers to kernels.") else: - buf_indices_and_args.append(cl_arg_idx) - buf_indices_and_args.append( - f"pack('{arg_char}{arg_char}', {arg_var}.real, {arg_var}.imag)") + buf_indices_and_args.extend( + (cl_arg_idx, + f"pack('{arg_char}{arg_char}', {arg_var}.real, {arg_var}.imag)") + ) cl_arg_idx += 1 fp_arg_count += 2 diff --git a/pyopencl/tools.py b/pyopencl/tools.py index 0e0dd4c43..c960b63ad 100644 --- a/pyopencl/tools.py +++ b/pyopencl/tools.py @@ -964,18 +964,12 @@ def get_gl_sharing_context_properties() -> list[tuple[cl.context_properties, Any import sys if sys.platform in ["linux", "linux2"]: from OpenGL import GLX - props.append( - (ctx_props.GL_CONTEXT_KHR, GLX.glXGetCurrentContext())) - props.append( - (ctx_props.GLX_DISPLAY_KHR, - GLX.glXGetCurrentDisplay())) + props.extend(((ctx_props.GL_CONTEXT_KHR, GLX.glXGetCurrentContext()), + (ctx_props.GLX_DISPLAY_KHR, GLX.glXGetCurrentDisplay()))) elif sys.platform == "win32": from OpenGL import WGL - props.append( - (ctx_props.GL_CONTEXT_KHR, gl_platform.GetCurrentContext())) - props.append( - (ctx_props.WGL_HDC_KHR, - WGL.wglGetCurrentDC())) + props.extend(((ctx_props.GL_CONTEXT_KHR, gl_platform.GetCurrentContext()), + (ctx_props.WGL_HDC_KHR, WGL.wglGetCurrentDC()))) elif sys.platform == "darwin": props.append( (ctx_props.CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, diff --git a/pyproject.toml b/pyproject.toml index 73688a4a3..3d07c2762 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -103,6 +103,7 @@ extend-ignore = [ "type-check-without-type-error", "blind-except", "try-consider-else", + "pytest-parameter-with-default-argument", # FIXME: This is a longer discussion... "non-empty-init-module", diff --git a/test/test_array.py b/test/test_array.py index be5b4b0cc..537edf922 100644 --- a/test/test_array.py +++ b/test/test_array.py @@ -1610,7 +1610,7 @@ def test_multi_put(ctx_factory: cl.CtxFactory): ] out_compare = [np.zeros((10,), np.float32) for i in range(9)] - for _i, ary in enumerate(out_compare): + for ary in out_compare: ary[idx.get()] = np.arange(0, 6, dtype=np.float32) cl_array.multi_put(cl_arrays, idx, out=out_arrays) diff --git a/test/test_wrapper.py b/test/test_wrapper.py index 3870cf1d0..d68795a98 100644 --- a/test/test_wrapper.py +++ b/test/test_wrapper.py @@ -207,7 +207,7 @@ def do_test(cl_obj, info_cls, func=None, try_attr_form=True): if profiling: evt.wait() do_test(evt, cl.profiling_info, - lambda info: evt.get_profiling_info(info), + evt.get_profiling_info, try_attr_form=False) # crashes on intel... @@ -230,7 +230,7 @@ def do_test(cl_obj, info_cls, func=None, try_attr_form=True): img.depth # ruff:ignore[useless-expression] img.image.depth # ruff:ignore[useless-expression] do_test(img, cl.image_info, - lambda info: img.get_image_info(info)) + img.get_image_info) # }}} From 72332660305e16e9e9fbfad5220789de872f05a4 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 28 Aug 2026 16:47:02 -0500 Subject: [PATCH 2/2] Update baseline --- .basedpyright/baseline.json | 164 +++++++----------------------------- 1 file changed, 30 insertions(+), 134 deletions(-) diff --git a/.basedpyright/baseline.json b/.basedpyright/baseline.json index 6d920e136..f0976adba 100644 --- a/.basedpyright/baseline.json +++ b/.basedpyright/baseline.json @@ -97,54 +97,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 23, - "endColumn": 27, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 23, - "endColumn": 27, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 29, - "endColumn": 33, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 29, - "endColumn": 33, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 40, - "endColumn": 44, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 40, - "endColumn": 44, - "lineCount": 1 - } - }, { "code": "reportUnknownVariableType", "range": { @@ -19343,14 +19295,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 12, - "endColumn": 39, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -19647,22 +19591,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 12, - "endColumn": 39, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 12, - "endColumn": 39, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -19687,14 +19615,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 12, - "endColumn": 39, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -19711,14 +19631,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 16, - "endColumn": 43, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -22274,64 +22186,56 @@ { "code": "reportUnknownArgumentType", "range": { - "startColumn": 12, - "endColumn": 66, - "lineCount": 1 + "startColumn": 21, + "endColumn": 68, + "lineCount": 2 } }, { "code": "reportUnknownMemberType", "range": { - "startColumn": 13, - "endColumn": 37, + "startColumn": 23, + "endColumn": 47, "lineCount": 1 } }, { "code": "reportAttributeAccessIssue", "range": { - "startColumn": 23, - "endColumn": 37, + "startColumn": 33, + "endColumn": 47, "lineCount": 1 } }, { "code": "reportUnknownMemberType", "range": { - "startColumn": 39, - "endColumn": 63, + "startColumn": 49, + "endColumn": 73, "lineCount": 1 } }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 16, - "endColumn": 47, - "lineCount": 2 - } - }, { "code": "reportUnknownMemberType", "range": { - "startColumn": 17, - "endColumn": 42, + "startColumn": 13, + "endColumn": 38, "lineCount": 1 } }, { "code": "reportAttributeAccessIssue", "range": { - "startColumn": 27, - "endColumn": 42, + "startColumn": 23, + "endColumn": 38, "lineCount": 1 } }, { "code": "reportUnknownMemberType", "range": { - "startColumn": 20, - "endColumn": 44, + "startColumn": 40, + "endColumn": 64, "lineCount": 1 } }, @@ -22354,64 +22258,56 @@ { "code": "reportUnknownArgumentType", "range": { - "startColumn": 12, - "endColumn": 71, - "lineCount": 1 + "startColumn": 21, + "endColumn": 59, + "lineCount": 2 } }, { "code": "reportUnknownMemberType", "range": { - "startColumn": 13, - "endColumn": 37, + "startColumn": 23, + "endColumn": 47, "lineCount": 1 } }, { "code": "reportAttributeAccessIssue", "range": { - "startColumn": 23, - "endColumn": 37, + "startColumn": 33, + "endColumn": 47, "lineCount": 1 } }, { "code": "reportUnknownMemberType", "range": { - "startColumn": 39, - "endColumn": 68, + "startColumn": 49, + "endColumn": 78, "lineCount": 1 } }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 16, - "endColumn": 42, - "lineCount": 2 - } - }, { "code": "reportUnknownMemberType", "range": { - "startColumn": 17, - "endColumn": 38, + "startColumn": 13, + "endColumn": 34, "lineCount": 1 } }, { "code": "reportAttributeAccessIssue", "range": { - "startColumn": 27, - "endColumn": 38, + "startColumn": 23, + "endColumn": 34, "lineCount": 1 } }, { "code": "reportUnknownMemberType", "range": { - "startColumn": 20, - "endColumn": 39, + "startColumn": 36, + "endColumn": 55, "lineCount": 1 } },