From 1fd64c8cce6c8a7435ab683e5eb212f2f731fee5 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Tue, 14 Oct 2025 18:49:32 +0100 Subject: [PATCH] chore(dev): Run `cython-lint` against codebase (except `cuda_bindings`), add it to `pre-commit` --- .pre-commit-config.yaml | 7 +++++++ cuda_core/cuda/core/experimental/_context.pyx | 1 - cuda_core/cuda/core/experimental/_memory.pyx | 5 ----- cuda_core/cuda/core/experimental/_memoryview.pyx | 6 ++---- cuda_core/cuda/core/experimental/_stream.pyx | 2 -- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 10b36ce70e..bb564d0fe8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -78,5 +78,12 @@ repos: hooks: - id: actionlint + - repo: https://github.com/MarcoGorelli/cython-lint + rev: "d9ff7ce99ef4f2ae8fba93079ca9d76c4651d4ac" # frozen: v0.18.0 + hooks: + - id: cython-lint + args: [--no-pycodestyle] + exclude: ^cuda_bindings/ + default_language_version: python: python3 diff --git a/cuda_core/cuda/core/experimental/_context.pyx b/cuda_core/cuda/core/experimental/_context.pyx index b03828a1b2..d6ccf32316 100644 --- a/cuda_core/cuda/core/experimental/_context.pyx +++ b/cuda_core/cuda/core/experimental/_context.pyx @@ -4,7 +4,6 @@ from dataclasses import dataclass -from cuda.core.experimental._utils.clear_error_support import assert_type from cuda.core.experimental._utils.cuda_utils import driver diff --git a/cuda_core/cuda/core/experimental/_memory.pyx b/cuda_core/cuda/core/experimental/_memory.pyx index 34e9d18e4b..024ffa2aef 100644 --- a/cuda_core/cuda/core/experimental/_memory.pyx +++ b/cuda_core/cuda/core/experimental/_memory.pyx @@ -20,8 +20,6 @@ from cuda.core.experimental._utils.cuda_utils cimport ( ) import abc -import array -import contextlib import cython from dataclasses import dataclass, field from typing import Iterable, Literal, Optional, TYPE_CHECKING, TypeVar, Union @@ -34,9 +32,6 @@ from cuda.core.experimental._dlpack import DLDeviceType, make_py_capsule from cuda.core.experimental._stream import Stream from cuda.core.experimental._utils.cuda_utils import ( driver, Transaction, get_binding_version ) -if platform.system() == "Linux": - import socket - if TYPE_CHECKING: from ._device import Device import uuid diff --git a/cuda_core/cuda/core/experimental/_memoryview.pyx b/cuda_core/cuda/core/experimental/_memoryview.pyx index 6bec14def3..3ae7fed14f 100644 --- a/cuda_core/cuda/core/experimental/_memoryview.pyx +++ b/cuda_core/cuda/core/experimental/_memoryview.pyx @@ -2,12 +2,10 @@ # # SPDX-License-Identifier: Apache-2.0 -cimport cython - from ._dlpack cimport * import functools -from typing import Any, Optional +from typing import Optional import numpy @@ -226,7 +224,7 @@ cdef class _StridedMemoryViewProxy: cdef StridedMemoryView view_as_dlpack(obj, stream_ptr, view=None): - cdef int dldevice, device_id, i + cdef int dldevice, device_id cdef bint is_device_accessible, is_readonly is_device_accessible = False dldevice, device_id = obj.__dlpack_device__() diff --git a/cuda_core/cuda/core/experimental/_stream.pyx b/cuda_core/cuda/core/experimental/_stream.pyx index 4afde6baff..e2a418ac27 100644 --- a/cuda_core/cuda/core/experimental/_stream.pyx +++ b/cuda_core/cuda/core/experimental/_stream.pyx @@ -18,7 +18,6 @@ from cuda.core.experimental._utils.cuda_utils cimport ( ) import cython -import os import warnings from dataclasses import dataclass from typing import TYPE_CHECKING, Optional, Protocol, Union @@ -29,7 +28,6 @@ if TYPE_CHECKING: from cuda.core.experimental._context import Context from cuda.core.experimental._event import Event, EventOptions from cuda.core.experimental._graph import GraphBuilder -from cuda.core.experimental._utils.clear_error_support import assert_type from cuda.core.experimental._utils.cuda_utils import ( driver, )