diff --git a/doc/conf.py b/doc/conf.py index 06b30cd61..f785f6ac9 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -40,4 +40,4 @@ def setup(app: Sphinx) -> None: - app.connect("missing-reference", process_autodoc_missing_reference) # noqa: F821 + app.connect("missing-reference", process_autodoc_missing_reference) # ruff:ignore[undefined-name] diff --git a/examples/ipython-demo.ipynb b/examples/ipython-demo.ipynb index bbc47ab13..40837d68b 100644 --- a/examples/ipython-demo.ipynb +++ b/examples/ipython-demo.ipynb @@ -153,7 +153,7 @@ }, "outputs": [], "source": [ - "sum_vector(queue, (n,), None, a.data, b.data, c.data) # noqa: F821" + "sum_vector(queue, (n,), None, a.data, b.data, c.data) # ruff:ignore[undefined-name]" ] }, { diff --git a/examples/pi-monte-carlo.py b/examples/pi-monte-carlo.py index 44f32b63b..ba942e165 100644 --- a/examples/pi-monte-carlo.py +++ b/examples/pi-monte-carlo.py @@ -484,7 +484,7 @@ def MetropolisCuda(InputCU): ) # mod = SourceModule(KernelCodeCuda(),nvcc='nvcc',keep=True) # Needed to set the compiler via ccbin for CUDA9 implementation - # mod = SourceModule(KernelCodeCuda(),options=['-ccbin','clang-3.9','--compiler-options','-DTRNG=%i' % Marsaglia[RNG],'-DTYPE=%s' % Computing[ValueType],'-DTEST=%s' % Test[TestType]],keep=True) # noqa: E501 + # mod = SourceModule(KernelCodeCuda(),options=['-ccbin','clang-3.9','--compiler-options','-DTRNG=%i' % Marsaglia[RNG],'-DTYPE=%s' % Computing[ValueType],'-DTEST=%s' % Test[TestType]],keep=True) # ruff:ignore[line-too-long] except Exception: print("Compilation seems to break") @@ -771,7 +771,7 @@ def FitAndPrint(N, D, Curves): # Seeds for RNG Seeds = 110271, 101008 - HowToUse = "%s -o (Out of Core Metrology) -c (Print Curves) -k (Case On IfThen) -d -g -i -b -e -s -f -l -t -r -m -v " # noqa: E501 + HowToUse = "%s -o (Out of Core Metrology) -c (Print Curves) -k (Case On IfThen) -d -g -i -b -e -s -f -l -t -r -m -v " # ruff:ignore[line-too-long] try: opts, args = getopt.getopt( @@ -1031,7 +1031,7 @@ def FitAndPrint(N, D, Curves): Inside = OutputCU["Inside"] NewIterations = OutputCU["NewIterations"] Duration = OutputCU["Duration"] - pycuda.context.pop() # noqa: F821 + pycuda.context.pop() # ruff:ignore[undefined-name] except Exception: print( "Problem with (%i,%i) // computations on Cuda" @@ -1159,4 +1159,4 @@ def FitAndPrint(N, D, Curves): if Fit: # FIXME: undefined var 'median' - FitAndPrint(ExploredJobs, median, Curves) # noqa: F821 + FitAndPrint(ExploredJobs, median, Curves) # ruff:ignore[undefined-name] diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 8b7f5a8f2..b9f42983c 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -72,7 +72,7 @@ SVMInnerT, WaitList, ) -from pyopencl._cl import ( # noqa: F401 +from pyopencl._cl import ( # ruff:ignore[unused-import] get_cl_header_version, program_kind, status_code, @@ -219,7 +219,7 @@ from pyopencl._cl import UserEvent if get_cl_header_version() >= (1, 2): from pyopencl._cl import ImageDescriptor - from pyopencl._cl import ( # noqa: F401 + from pyopencl._cl import ( # ruff:ignore[unused-import] _enqueue_barrier_with_wait_list, _enqueue_fill_buffer, _enqueue_marker_with_wait_list, enqueue_fill_image, enqueue_migrate_mem_objects, unload_platform_compiler) @@ -473,7 +473,7 @@ def __getattr__(self, attr: str) -> Kernel: knl = Kernel(self, attr) # Nvidia does not raise errors even for invalid names, # but this will give an error if the kernel is invalid. - knl.num_args # noqa: B018 + knl.num_args # ruff:ignore[useless-expression] count = self._knl_retrieval_count[attr] = ( self._knl_retrieval_count.get(attr, 0) + 1) @@ -1490,8 +1490,8 @@ def enqueue_fill(queue: CommandQueue, np.dtype(np.uint8): channel_type.UNSIGNED_INT8, } try: - np.float16 # noqa: B018 -except Exception: # noqa: S110 + np.float16 # ruff:ignore[useless-expression] +except Exception: # ruff:ignore[try-except-pass] pass else: DTYPE_TO_CHANNEL_TYPE[np.dtype(np.float16)] = channel_type.HALF_FLOAT diff --git a/pyopencl/_cl.pyi b/pyopencl/_cl.pyi index 3497426cc..73572bc5b 100644 --- a/pyopencl/_cl.pyi +++ b/pyopencl/_cl.pyi @@ -57,7 +57,7 @@ class LogicError(Error): class RuntimeError(Error): ... -class status_code(IntEnum): # noqa: N801 +class status_code(IntEnum): # ruff:ignore[invalid-class-name] SUCCESS = auto() DEVICE_NOT_FOUND = auto() DEVICE_NOT_AVAILABLE = auto() @@ -123,7 +123,7 @@ class status_code(IntEnum): # noqa: N801 MAX_SIZE_RESTRICTION_EXCEEDED = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class platform_info(IntEnum): # noqa: N801 +class platform_info(IntEnum): # ruff:ignore[invalid-class-name] PROFILE = auto() VERSION = auto() NAME = auto() @@ -134,7 +134,7 @@ class platform_info(IntEnum): # noqa: N801 EXTENSIONS_WITH_VERSION = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_type(IntEnum): # noqa: N801 +class device_type(IntEnum): # ruff:ignore[invalid-class-name] DEFAULT = auto() CPU = auto() GPU = auto() @@ -143,7 +143,7 @@ class device_type(IntEnum): # noqa: N801 ALL = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_info(IntEnum): # noqa: N801 +class device_info(IntEnum): # ruff:ignore[invalid-class-name] TYPE = auto() VENDOR_ID = auto() MAX_COMPUTE_UNITS = auto() @@ -294,11 +294,11 @@ class device_info(IntEnum): # noqa: N801 NUM_SIMULTANEOUS_INTEROPS_INTEL = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_topology_type_amd(IntEnum): # noqa: N801 +class device_topology_type_amd(IntEnum): # ruff:ignore[invalid-class-name] PCIE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_fp_config(IntEnum): # noqa: N801 +class device_fp_config(IntEnum): # ruff:ignore[invalid-class-name] DENORM = auto() INF_NAN = auto() ROUND_TO_NEAREST = auto() @@ -309,30 +309,30 @@ class device_fp_config(IntEnum): # noqa: N801 CORRECTLY_ROUNDED_DIVIDE_SQRT = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_mem_cache_type(IntEnum): # noqa: N801 +class device_mem_cache_type(IntEnum): # ruff:ignore[invalid-class-name] NONE = auto() READ_ONLY_CACHE = auto() READ_WRITE_CACHE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_local_mem_type(IntEnum): # noqa: N801 +class device_local_mem_type(IntEnum): # ruff:ignore[invalid-class-name] LOCAL = auto() GLOBAL = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_exec_capabilities(IntEnum): # noqa: N801 +class device_exec_capabilities(IntEnum): # ruff:ignore[invalid-class-name] KERNEL = auto() NATIVE_KERNEL = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_svm_capabilities(IntEnum): # noqa: N801 +class device_svm_capabilities(IntEnum): # ruff:ignore[invalid-class-name] COARSE_GRAIN_BUFFER = auto() FINE_GRAIN_BUFFER = auto() FINE_GRAIN_SYSTEM = auto() ATOMICS = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class command_queue_properties(IntEnum): # noqa: N801 +class command_queue_properties(IntEnum): # ruff:ignore[invalid-class-name] _zero = 0 OUT_OF_ORDER_EXEC_MODE_ENABLE = auto() PROFILING_ENABLE = auto() @@ -340,7 +340,7 @@ class command_queue_properties(IntEnum): # noqa: N801 ON_DEVICE_DEFAULT = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class context_info(IntEnum): # noqa: N801 +class context_info(IntEnum): # ruff:ignore[invalid-class-name] REFERENCE_COUNT = auto() DEVICES = auto() PROPERTIES = auto() @@ -348,15 +348,15 @@ class context_info(IntEnum): # noqa: N801 INTEROP_USER_SYNC = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class gl_context_info(IntEnum): # noqa: N801 +class gl_context_info(IntEnum): # ruff:ignore[invalid-class-name] to_string = classmethod(pyopencl._monkeypatch.to_string) -class context_properties(IntEnum): # noqa: N801 +class context_properties(IntEnum): # ruff:ignore[invalid-class-name] PLATFORM = auto() OFFLINE_DEVICES_AMD = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class command_queue_info(IntEnum): # noqa: N801 +class command_queue_info(IntEnum): # ruff:ignore[invalid-class-name] CONTEXT = auto() DEVICE = auto() REFERENCE_COUNT = auto() @@ -364,13 +364,13 @@ class command_queue_info(IntEnum): # noqa: N801 PROPERTIES_ARRAY = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class queue_properties(IntEnum): # noqa: N801 +class queue_properties(IntEnum): # ruff:ignore[invalid-class-name] PROPERTIES = auto() SIZE = auto() DEVICE_DEFAULT = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class mem_flags(IntEnum): # noqa: N801 +class mem_flags(IntEnum): # ruff:ignore[invalid-class-name] READ_WRITE = auto() WRITE_ONLY = auto() READ_ONLY = auto() @@ -384,7 +384,7 @@ class mem_flags(IntEnum): # noqa: N801 KERNEL_READ_AND_WRITE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class svm_mem_flags(IntEnum): # noqa: N801 +class svm_mem_flags(IntEnum): # ruff:ignore[invalid-class-name] READ_WRITE = auto() WRITE_ONLY = auto() READ_ONLY = auto() @@ -392,7 +392,7 @@ class svm_mem_flags(IntEnum): # noqa: N801 SVM_ATOMICS = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class channel_order(IntEnum): # noqa: N801 +class channel_order(IntEnum): # ruff:ignore[invalid-class-name] R = auto() A = auto() RG = auto() @@ -405,14 +405,14 @@ class channel_order(IntEnum): # noqa: N801 Rx = auto() RGx = auto() RGBx = auto() - sRGB = auto() # noqa: N815 - sRGBx = auto() # noqa: N815 - sRGBA = auto() # noqa: N815 - sBGRA = auto() # noqa: N815 + sRGB = auto() # ruff:ignore[mixed-case-variable-in-class-scope] + sRGBx = auto() # ruff:ignore[mixed-case-variable-in-class-scope] + sRGBA = auto() # ruff:ignore[mixed-case-variable-in-class-scope] + sBGRA = auto() # ruff:ignore[mixed-case-variable-in-class-scope] ABGR = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class channel_type(IntEnum): # noqa: N801 +class channel_type(IntEnum): # ruff:ignore[invalid-class-name] SNORM_INT8 = auto() SNORM_INT16 = auto() UNORM_INT8 = auto() @@ -431,7 +431,7 @@ class channel_type(IntEnum): # noqa: N801 UNORM_INT_101010_2 = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class mem_object_type(IntEnum): # noqa: N801 +class mem_object_type(IntEnum): # ruff:ignore[invalid-class-name] BUFFER = auto() IMAGE2D = auto() IMAGE3D = auto() @@ -442,7 +442,7 @@ class mem_object_type(IntEnum): # noqa: N801 PIPE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class mem_info(IntEnum): # noqa: N801 +class mem_info(IntEnum): # ruff:ignore[invalid-class-name] TYPE = auto() FLAGS = auto() SIZE = auto() @@ -456,7 +456,7 @@ class mem_info(IntEnum): # noqa: N801 PROPERTIES = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class image_info(IntEnum): # noqa: N801 +class image_info(IntEnum): # ruff:ignore[invalid-class-name] FORMAT = auto() ELEMENT_SIZE = auto() ROW_PITCH = auto() @@ -470,18 +470,18 @@ class image_info(IntEnum): # noqa: N801 NUM_SAMPLES = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class pipe_info(IntEnum): # noqa: N801 +class pipe_info(IntEnum): # ruff:ignore[invalid-class-name] PACKET_SIZE = auto() MAX_PACKETS = auto() PROPERTIES = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class pipe_properties(IntEnum): # noqa: N801 +class pipe_properties(IntEnum): # ruff:ignore[invalid-class-name] PACKET_SIZE = auto() MAX_PACKETS = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class addressing_mode(IntEnum): # noqa: N801 +class addressing_mode(IntEnum): # ruff:ignore[invalid-class-name] NONE = auto() CLAMP_TO_EDGE = auto() CLAMP = auto() @@ -489,12 +489,12 @@ class addressing_mode(IntEnum): # noqa: N801 MIRRORED_REPEAT = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class filter_mode(IntEnum): # noqa: N801 +class filter_mode(IntEnum): # ruff:ignore[invalid-class-name] NEAREST = auto() LINEAR = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class sampler_info(IntEnum): # noqa: N801 +class sampler_info(IntEnum): # ruff:ignore[invalid-class-name] REFERENCE_COUNT = auto() CONTEXT = auto() NORMALIZED_COORDS = auto() @@ -509,19 +509,19 @@ class sampler_info(IntEnum): # noqa: N801 LOD_MAX_KHR = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class sampler_properties(IntEnum): # noqa: N801 +class sampler_properties(IntEnum): # ruff:ignore[invalid-class-name] NORMALIZED_COORDS = auto() ADDRESSING_MODE = auto() FILTER_MODE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class map_flags(IntEnum): # noqa: N801 +class map_flags(IntEnum): # ruff:ignore[invalid-class-name] READ = auto() WRITE = auto() WRITE_INVALIDATE_REGION = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class program_info(IntEnum): # noqa: N801 +class program_info(IntEnum): # ruff:ignore[invalid-class-name] REFERENCE_COUNT = auto() CONTEXT = auto() NUM_DEVICES = auto() @@ -536,7 +536,7 @@ class program_info(IntEnum): # noqa: N801 SCOPE_GLOBAL_DTORS_PRESENT = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class program_build_info(IntEnum): # noqa: N801 +class program_build_info(IntEnum): # ruff:ignore[invalid-class-name] STATUS = auto() OPTIONS = auto() LOG = auto() @@ -544,14 +544,14 @@ class program_build_info(IntEnum): # noqa: N801 GLOBAL_VARIABLE_TOTAL_SIZE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class program_binary_type(IntEnum): # noqa: N801 +class program_binary_type(IntEnum): # ruff:ignore[invalid-class-name] NONE = auto() COMPILED_OBJECT = auto() LIBRARY = auto() EXECUTABLE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class kernel_info(IntEnum): # noqa: N801 +class kernel_info(IntEnum): # ruff:ignore[invalid-class-name] FUNCTION_NAME = auto() NUM_ARGS = auto() REFERENCE_COUNT = auto() @@ -560,7 +560,7 @@ class kernel_info(IntEnum): # noqa: N801 ATTRIBUTES = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class kernel_arg_info(IntEnum): # noqa: N801 +class kernel_arg_info(IntEnum): # ruff:ignore[invalid-class-name] ADDRESS_QUALIFIER = auto() ACCESS_QUALIFIER = auto() TYPE_NAME = auto() @@ -568,21 +568,21 @@ class kernel_arg_info(IntEnum): # noqa: N801 NAME = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class kernel_arg_address_qualifier(IntEnum): # noqa: N801 +class kernel_arg_address_qualifier(IntEnum): # ruff:ignore[invalid-class-name] GLOBAL = auto() LOCAL = auto() CONSTANT = auto() PRIVATE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class kernel_arg_access_qualifier(IntEnum): # noqa: N801 +class kernel_arg_access_qualifier(IntEnum): # ruff:ignore[invalid-class-name] READ_ONLY = auto() WRITE_ONLY = auto() READ_WRITE = auto() NONE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class kernel_arg_type_qualifier(IntEnum): # noqa: N801 +class kernel_arg_type_qualifier(IntEnum): # ruff:ignore[invalid-class-name] NONE = auto() CONST = auto() RESTRICT = auto() @@ -590,7 +590,7 @@ class kernel_arg_type_qualifier(IntEnum): # noqa: N801 PIPE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class kernel_work_group_info(IntEnum): # noqa: N801 +class kernel_work_group_info(IntEnum): # ruff:ignore[invalid-class-name] WORK_GROUP_SIZE = 0x11B0 COMPILE_WORK_GROUP_SIZE = 0x11B1 LOCAL_MEM_SIZE = 0x11B2 @@ -599,7 +599,7 @@ class kernel_work_group_info(IntEnum): # noqa: N801 GLOBAL_WORK_SIZE = 0x11B5 to_string = classmethod(pyopencl._monkeypatch.to_string) -class kernel_sub_group_info(IntEnum): # noqa: N801 +class kernel_sub_group_info(IntEnum): # ruff:ignore[invalid-class-name] MAX_SUB_GROUP_SIZE_FOR_NDRANGE = auto() SUB_GROUP_COUNT_FOR_NDRANGE = auto() LOCAL_SIZE_FOR_SUB_GROUP_COUNT = auto() @@ -607,7 +607,7 @@ class kernel_sub_group_info(IntEnum): # noqa: N801 COMPILE_NUM_SUB_GROUPS = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class event_info(IntEnum): # noqa: N801 +class event_info(IntEnum): # ruff:ignore[invalid-class-name] COMMAND_QUEUE = auto() COMMAND_TYPE = auto() REFERENCE_COUNT = auto() @@ -615,7 +615,7 @@ class event_info(IntEnum): # noqa: N801 CONTEXT = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class command_type(IntEnum): # noqa: N801 +class command_type(IntEnum): # ruff:ignore[invalid-class-name] NDRANGE_KERNEL = auto() TASK = auto() NATIVE_KERNEL = auto() @@ -649,14 +649,14 @@ class command_type(IntEnum): # noqa: N801 SVM_MIGRATE_MEM = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class command_execution_status(IntEnum): # noqa: N801 +class command_execution_status(IntEnum): # ruff:ignore[invalid-class-name] COMPLETE = auto() RUNNING = auto() SUBMITTED = auto() QUEUED = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class profiling_info(IntEnum): # noqa: N801 +class profiling_info(IntEnum): # ruff:ignore[invalid-class-name] QUEUED = auto() SUBMIT = auto() START = auto() @@ -664,19 +664,19 @@ class profiling_info(IntEnum): # noqa: N801 COMPLETE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class mem_migration_flags(IntEnum): # noqa: N801 +class mem_migration_flags(IntEnum): # ruff:ignore[invalid-class-name] HOST = auto() CONTENT_UNDEFINED = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_partition_property(IntEnum): # noqa: N801 +class device_partition_property(IntEnum): # ruff:ignore[invalid-class-name] EQUALLY = auto() BY_COUNTS = auto() BY_COUNTS_LIST_END = auto() BY_AFFINITY_DOMAIN = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_affinity_domain(IntEnum): # noqa: N801 +class device_affinity_domain(IntEnum): # ruff:ignore[invalid-class-name] NUMA = auto() L4_CACHE = auto() L3_CACHE = auto() @@ -685,7 +685,7 @@ class device_affinity_domain(IntEnum): # noqa: N801 NEXT_PARTITIONABLE = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_atomic_capabilities(IntEnum): # noqa: N801 +class device_atomic_capabilities(IntEnum): # ruff:ignore[invalid-class-name] ORDER_RELAXED = auto() ORDER_ACQ_REL = auto() ORDER_SEQ_CST = auto() @@ -695,12 +695,12 @@ class device_atomic_capabilities(IntEnum): # noqa: N801 SCOPE_ALL_DEVICES = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class device_device_enqueue_capabilities(IntEnum): # noqa: N801 +class device_device_enqueue_capabilities(IntEnum): # ruff:ignore[invalid-class-name] SUPPORTED = auto() REPLACEABLE_DEFAULT = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class version_bits(IntEnum): # noqa: N801 +class version_bits(IntEnum): # ruff:ignore[invalid-class-name] MAJOR_BITS = auto() MINOR_BITS = auto() PATCH_BITS = auto() @@ -709,12 +709,12 @@ class version_bits(IntEnum): # noqa: N801 PATCH_MASK = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class khronos_vendor_id(IntEnum): # noqa: N801 +class khronos_vendor_id(IntEnum): # ruff:ignore[invalid-class-name] CODEPLAY = auto() to_string = classmethod(pyopencl._monkeypatch.to_string) -class gl_object_type(IntEnum): # noqa: N801 +class gl_object_type(IntEnum): # ruff:ignore[invalid-class-name] BUFFER = auto() TEXTURE2D = auto() TEXTURE3D = auto() @@ -722,7 +722,7 @@ class gl_object_type(IntEnum): # noqa: N801 to_string = pyopencl._monkeypatch.to_string -class gl_texture_info(IntEnum): # noqa: N801 +class gl_texture_info(IntEnum): # ruff:ignore[invalid-class-name] TEXTURE_TARGET = auto() MIPMAP_LEVEL = auto() @@ -1672,7 +1672,7 @@ class Sampler: lod_min_khr: float lod_max_khr: float -class program_kind(IntEnum): # noqa: N801 +class program_kind(IntEnum): # ruff:ignore[invalid-class-name] UNKNOWN = auto() SOURCE = auto() BINARY = auto() diff --git a/pyopencl/_monkeypatch.py b/pyopencl/_monkeypatch.py index 03f36f89e..ab3ca24df 100644 --- a/pyopencl/_monkeypatch.py +++ b/pyopencl/_monkeypatch.py @@ -491,7 +491,7 @@ def image_shape(self: _cl.Image) -> tuple[int, int] | tuple[int, int, int]: def error_str(self: _cl.Error) -> str: val = self.what try: - val.routine # noqa: B018 + val.routine # ruff:ignore[useless-expression] except AttributeError: return str(val) else: diff --git a/pyopencl/_mymako.py b/pyopencl/_mymako.py index c0209838a..074ca89df 100644 --- a/pyopencl/_mymako.py +++ b/pyopencl/_mymako.py @@ -2,7 +2,7 @@ try: - import mako.template # noqa: F401 + import mako.template # ruff:ignore[unused-import] except ImportError as err: raise ImportError( "Some of PyOpenCL's facilities require the Mako templating engine.\n" @@ -14,4 +14,4 @@ "- aptitude install python-mako\n" "\nor whatever else is appropriate for your system.") from err -from mako import * # noqa: F403 +from mako import * # ruff:ignore[undefined-local-with-import-star] diff --git a/pyopencl/array.py b/pyopencl/array.py index 67749da82..09eb771f9 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -282,7 +282,7 @@ def __init__(self, val="The operation you are attempting does not yet " ValueError.__init__(self, val) -class _copy_queue: # noqa: N801 +class _copy_queue: # ruff:ignore[invalid-class-name] pass @@ -613,7 +613,7 @@ def __init__( # }}} assert dtype != object, \ - "object arrays on the compute device are not allowed" # noqa: E721 + "object arrays on the compute device are not allowed" # ruff:ignore[type-comparison] assert isinstance(shape, tuple) assert isinstance(strides, tuple) @@ -2097,7 +2097,7 @@ def transpose(self, axes=None): strides=tuple(new_strides)) @property - def T(self): # noqa: N802 + def T(self): # ruff:ignore[invalid-function-name] """ .. versionadded:: 2015.2 """ @@ -2351,7 +2351,7 @@ def as_strided(ary, shape=None, strides=None): data=ary.data, strides=strides) -class _same_as_transfer: # noqa: N801 +class _same_as_transfer: # ruff:ignore[invalid-class-name] pass @@ -2846,7 +2846,7 @@ def concatenate(arrays, axis=0, queue: cl.CommandQueue | None = None, allocator= shape = tuple(shape) dtype = np.result_type(*[ary.dtype for ary in arrays]) - if __debug__ and builtins.any(type(ary) != type(arrays[0]) # noqa: E721 + if __debug__ and builtins.any(type(ary) != type(arrays[0]) # ruff:ignore[type-comparison] for ary in arrays[1:]): warn("Elements of 'arrays' not of the same type, returning " "an instance of the type of arrays[0]", @@ -2912,7 +2912,7 @@ def hstack(arrays, queue: cl.CommandQueue | None = None): w = builtins.sum(ary.shape[-1] for ary in arrays) - if __debug__ and builtins.any(type(ary) != type(arrays[0]) # noqa: E721 + if __debug__ and builtins.any(type(ary) != type(arrays[0]) # ruff:ignore[type-comparison] for ary in arrays[1:]): warn("Elements of 'arrays' not of the same type, returning " "an instance of the type of arrays[0]", @@ -2969,7 +2969,7 @@ def stack(arrays, axis=0, queue: cl.CommandQueue | None = None): result_shape = (*input_shape[:axis], len(arrays), *input_shape[axis:]) - if __debug__ and builtins.any(type(ary) != type(arrays[0]) # noqa: E721 + if __debug__ and builtins.any(type(ary) != type(arrays[0]) # ruff:ignore[type-comparison] for ary in arrays[1:]): warn("Elements of 'arrays' not of the same type, returning " "an instance of the type of arrays[0]", diff --git a/pyopencl/bitonic_sort_templates.py b/pyopencl/bitonic_sort_templates.py index 78dfa16d1..16f3bec5e 100644 --- a/pyopencl/bitonic_sort_templates.py +++ b/pyopencl/bitonic_sort_templates.py @@ -96,7 +96,7 @@ % endif #define nsize ${nsize} //Total next dimensions sizes sum. (Block size) #define dsize ${dsize} //Dimension size -""" # noqa: E501 +""" # ruff:ignore[line-too-long] # }}} @@ -398,7 +398,7 @@ % endif for (int k=0;k<4;k++) data[i+k] = x[k]; } -""" # noqa: E501 +""" # ruff:ignore[line-too-long] # }}} @@ -446,7 +446,7 @@ // Write output out[i] = aux[i]; } -""" # noqa: E501 +""" # ruff:ignore[line-too-long] # }}} @@ -590,7 +590,7 @@ index[t*nsize] = iidx; % endif } -""" # noqa: E501 +""" # ruff:ignore[line-too-long] # }}} diff --git a/pyopencl/cache.py b/pyopencl/cache.py index 4e45e75f9..bec3d61b3 100644 --- a/pyopencl/cache.py +++ b/pyopencl/cache.py @@ -209,7 +209,7 @@ def _inner(src: bytes): if included_file_name not in result: try: - src_file = open(included_file_name, "rb") # noqa: SIM115 + src_file = open(included_file_name, "rb") # ruff:ignore[open-file-with-context-handler] except OSError: continue @@ -309,7 +309,7 @@ class _InvalidInfoFileError(RuntimeError): from pickle import load try: - info_file = open(info_path, "rb") # noqa: SIM115 + info_file = open(info_path, "rb") # ruff:ignore[open-file-with-context-handler] except OSError as err: raise _InvalidInfoFileError() from err diff --git a/pyopencl/characterize/__init__.py b/pyopencl/characterize/__init__.py index f4940b543..7d7895dae 100644 --- a/pyopencl/characterize/__init__.py +++ b/pyopencl/characterize/__init__.py @@ -56,7 +56,7 @@ def reasonable_work_group_size_multiple( ): try: return dev.warp_size_nv - except Exception: # noqa: S110 + except Exception: # ruff:ignore[try-except-pass] pass if ctx is None: @@ -285,7 +285,7 @@ def get_simd_group_size(dev: cl.Device, type_size: int): """ try: return dev.warp_size_nv - except Exception: # noqa: S110 + except Exception: # ruff:ignore[try-except-pass] pass lc_plat_vendor = dev.platform.vendor.lower() diff --git a/pyopencl/compyte b/pyopencl/compyte index 80ed45de9..f11783c33 160000 --- a/pyopencl/compyte +++ b/pyopencl/compyte @@ -1 +1 @@ -Subproject commit 80ed45de98b5432341763b9fa52a00fdac870b89 +Subproject commit f11783c33fe6f9ce06e55846dfdf741e4c15eb7f diff --git a/pyopencl/tools.py b/pyopencl/tools.py index c843194bc..421dffa9b 100644 --- a/pyopencl/tools.py +++ b/pyopencl/tools.py @@ -651,7 +651,7 @@ def _find_cl_obj( ) -> DeviceOrPlatformT: try: num = int(identifier) - except Exception: # noqa: S110 + except Exception: # ruff:ignore[try-except-pass] pass else: return objs[num] @@ -1632,7 +1632,7 @@ def is_spirv(s: str | bytes) -> TypeIs[bytes]: # {{{ numpy key types builder class _NumpyTypesKeyBuilder(KeyBuilderBase): # pyright: ignore[reportUnusedClass] - def update_for_VectorArg(self, key_hash: Hash, key: VectorArg) -> None: # noqa: N802 + def update_for_VectorArg(self, key_hash: Hash, key: VectorArg) -> None: # ruff:ignore[invalid-function-name] self.rec(key_hash, key.dtype) self.update_for_str(key_hash, key.name) self.rec(key_hash, key.with_offset) diff --git a/pyproject.toml b/pyproject.toml index 926447e1e..e537af831 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,21 +94,21 @@ extend-select = [ "TC", ] extend-ignore = [ - "E226", # missing whitespace around arithmetic operator - "E241", # multiple spaces after comma - "E402", # module level import not at the top of file "C90", # McCabe complexity - "UP031", # use f-strings instead of % - "UP032", # use f-strings instead of .format - "TRY004", - "BLE001", - "TRY300", + "missing-whitespace-around-arithmetic-operator", + "multiple-spaces-after-comma", + "module-import-not-at-top-of-file", + "printf-string-formatting", + "f-string", + "type-check-without-type-error", + "blind-except", + "try-consider-else", # FIXME: This is a longer discussion... - "RUF067", # __init__ should only contain reexports + "non-empty-init-module", # FIXME - "SIM102", + "collapsible-if", ] exclude = [ "examples/gl_interop_demo.py", @@ -117,18 +117,18 @@ exclude = [ ] [tool.ruff.lint.per-file-ignores] -"examples/pi-monte-carlo.py" = ["N", "B", "F841"] -"examples/black-hole-accretion.py" = ["N", "E501", "B", "SIM"] -"examples/n-body.py" = ["N", "E501", "PLW"] -"pyopencl/__init__.py" = ["I001"] -"contrib/fortran-to-opencl/translate.py" = ["N802", "N815", "B"] -"doc/*.py" = ["I002", "S102"] -"examples/*.py" = ["I002"] -"test/*.py" = ["I002", "BLE001"] -"test/test_*.py" = ["I002", "S102"] -"contrib/**/*.py" = ["I002"] -"*.ipynb" = ["I002"] -"pyopencl/_cl.pyi" = ["PYI052", "PYI002"] +"examples/pi-monte-carlo.py" = ["N", "B", "unused-variable"] +"examples/black-hole-accretion.py" = ["N", "line-too-long", "B", "SIM"] +"examples/n-body.py" = ["N", "line-too-long", "PLW"] +"pyopencl/__init__.py" = ["unsorted-imports"] +"contrib/fortran-to-opencl/translate.py" = ["invalid-function-name", "mixed-case-variable-in-class-scope", "B"] +"doc/*.py" = ["missing-required-import", "exec-builtin"] +"examples/*.py" = ["missing-required-import"] +"test/*.py" = ["missing-required-import", "blind-except"] +"test/test_*.py" = ["missing-required-import", "exec-builtin"] +"contrib/**/*.py" = ["missing-required-import"] +"*.ipynb" = ["missing-required-import"] +"pyopencl/_cl.pyi" = ["unannotated-assignment-in-stub", "complex-if-statement-in-stub"] [tool.ruff.lint.flake8-quotes] inline-quotes = "double" diff --git a/test/test_algorithm.py b/test/test_algorithm.py index c68624e05..b4e434a62 100644 --- a/test/test_algorithm.py +++ b/test/test_algorithm.py @@ -43,7 +43,7 @@ InclusiveScanKernel, ) from pyopencl.tools import ( - pytest_generate_tests_for_pyopencl as pytest_generate_tests, # noqa: F401 + pytest_generate_tests_for_pyopencl as pytest_generate_tests, # ruff:ignore[unused-import] ) diff --git a/test/test_array.py b/test/test_array.py index 7c615d032..be5b4b0cc 100644 --- a/test/test_array.py +++ b/test/test_array.py @@ -37,7 +37,7 @@ from pyopencl.characterize import has_double_support, has_struct_arg_count_bug from pyopencl.clrandom import PhiloxGenerator, ThreefryGenerator from pyopencl.tools import ( - pytest_generate_tests_for_pyopencl as pytest_generate_tests, # noqa: F401 + pytest_generate_tests_for_pyopencl as pytest_generate_tests, # ruff:ignore[unused-import] ) @@ -932,7 +932,7 @@ def test_random_int_in_range(ctx_factory: cl.CtxFactory, def test_numpy_integer_shape(ctx_factory: cl.CtxFactory): try: list(np.int32(17)) - except Exception: # noqa: S110 + except Exception: # ruff:ignore[try-except-pass] pass else: from pytest import skip diff --git a/test/test_arrays_in_structs.py b/test/test_arrays_in_structs.py index 3a3d3b100..3782b155f 100644 --- a/test/test_arrays_in_structs.py +++ b/test/test_arrays_in_structs.py @@ -26,7 +26,7 @@ import pyopencl.tools as cl_tools from pyopencl import cltypes, mem_flags from pyopencl.tools import ( - pytest_generate_tests_for_pyopencl as pytest_generate_tests, # noqa: F401 + pytest_generate_tests_for_pyopencl as pytest_generate_tests, # ruff:ignore[unused-import] ) diff --git a/test/test_clmath.py b/test/test_clmath.py index e2957ecf6..831eb82e2 100644 --- a/test/test_clmath.py +++ b/test/test_clmath.py @@ -30,7 +30,7 @@ from pyopencl import clmath from pyopencl.characterize import has_double_support, has_struct_arg_count_bug from pyopencl.tools import ( - pytest_generate_tests_for_pyopencl as pytest_generate_tests, # noqa: F401 + pytest_generate_tests_for_pyopencl as pytest_generate_tests, # ruff:ignore[unused-import] ) diff --git a/test/test_clrandom.py b/test/test_clrandom.py index f1fc861f8..6aef0c402 100644 --- a/test/test_clrandom.py +++ b/test/test_clrandom.py @@ -27,7 +27,7 @@ from pyopencl import clrandom, cltypes from pyopencl.characterize import has_double_support from pyopencl.tools import ( - pytest_generate_tests_for_pyopencl as pytest_generate_tests, # noqa: F401 + pytest_generate_tests_for_pyopencl as pytest_generate_tests, # ruff:ignore[unused-import] ) diff --git a/test/test_enqueue_copy.py b/test/test_enqueue_copy.py index ca3129d3e..6170f0d4d 100644 --- a/test/test_enqueue_copy.py +++ b/test/test_enqueue_copy.py @@ -26,7 +26,7 @@ import pyopencl as cl from pyopencl.characterize import get_pocl_version from pyopencl.tools import ( - pytest_generate_tests_for_pyopencl as pytest_generate_tests, # noqa: F401 + pytest_generate_tests_for_pyopencl as pytest_generate_tests, # ruff:ignore[unused-import] ) diff --git a/test/test_wrapper.py b/test/test_wrapper.py index be2e9de47..3870cf1d0 100644 --- a/test/test_wrapper.py +++ b/test/test_wrapper.py @@ -32,7 +32,7 @@ DeferredAllocator, ImmediateAllocator, MemoryPool, - pytest_generate_tests_for_pyopencl as pytest_generate_tests, # noqa: F401 + pytest_generate_tests_for_pyopencl as pytest_generate_tests, # ruff:ignore[unused-import] ) @@ -57,8 +57,8 @@ def test_get_info(ctx_factory: cl.CtxFactory): platform = device.platform with pytest.deprecated_call(): - device.persistent_unique_id # noqa: B018 - device.hashable_model_and_version_identifier # noqa: B018 + device.persistent_unique_id # ruff:ignore[useless-expression] + device.hashable_model_and_version_identifier # ruff:ignore[useless-expression] failure_count = [0] @@ -72,7 +72,7 @@ def test_get_info(ctx_factory: cl.CtxFactory): (cl.Program, cl.program_info.KERNEL_NAMES), (cl.Program, cl.program_info.NUM_KERNELS), ]) - CRASH_QUIRKS = [ # noqa: N806 + CRASH_QUIRKS = [ # ruff:ignore[non-lowercase-variable-in-function] (("NVIDIA Corporation", "NVIDIA CUDA", "OpenCL 1.0 CUDA 3.0.1"), [ @@ -107,7 +107,7 @@ def test_get_info(ctx_factory: cl.CtxFactory): (cl.Program, cl.program_info.SOURCE), ]), ] - QUIRKS = [] # noqa: N806 + QUIRKS = [] # ruff:ignore[non-lowercase-variable-in-function] def find_quirk(quirk_list, cl_obj, info): for (vendor, name, version), quirks in quirk_list: @@ -227,8 +227,8 @@ def do_test(cl_obj, info_cls, func=None, try_attr_form=True): img = cl.Image(ctx, cl.mem_flags.READ_ONLY, img_format, (128, 256)) assert img.shape == (128, 256) - img.depth # noqa: B018 - img.image.depth # noqa: B018 + 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)) @@ -299,7 +299,7 @@ def test_invalid_kernel_names_cause_failures(ctx_factory: cl.CtxFactory): """).build() try: - prg.sam # noqa: B018 + prg.sam # ruff:ignore[useless-expression] raise RuntimeError("invalid kernel name did not cause error") except AttributeError: pass