From 6dffb0305a8a746f8e5e5398655475367bf1fdd5 Mon Sep 17 00:00:00 2001 From: ViperEkura <3081035982@qq.com> Date: Tue, 4 Aug 2026 21:32:33 +0800 Subject: [PATCH] fix: satisfy ruff format and import lint in setup.py - Merge nested if for CUDA version mismatch check - Convert try-except-pass to return None (S110) - Apply ruff format --- setup.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 6f75376..b0eb501 100644 --- a/setup.py +++ b/setup.py @@ -62,14 +62,17 @@ class _CMakeBuildExt(_build_ext): nvcc_ver = _cuda_toolkit_version() torch_cuda = _torch_cuda_version() - if nvcc_ver is not None and torch_cuda is not None: - if nvcc_ver[0] != int(torch_cuda.split(".")[0]): - warnings.warn( - f"CUDA version mismatch: nvcc is {nvcc_ver[0]}.{nvcc_ver[1]} " - f"but torch was built with CUDA {torch_cuda}. " - f"Install a matching torch wheel.", - stacklevel=2, - ) + if ( + nvcc_ver is not None + and torch_cuda is not None + and nvcc_ver[0] != int(torch_cuda.split(".")[0]) + ): + warnings.warn( + f"CUDA version mismatch: nvcc is {nvcc_ver[0]}.{nvcc_ver[1]} " + f"but torch was built with CUDA {torch_cuda}. " + f"Install a matching torch wheel.", + stacklevel=2, + ) cmake = shutil.which("cmake") if cmake is None: @@ -92,9 +95,7 @@ class _CMakeBuildExt(_build_ext): if arch: cfg.append(f"-DASTRAI_CUDA_ARCH={arch}") subprocess.run(cfg, check=True) - subprocess.run( - [cmake, "--build", str(build_dir), "-j", parallel], check=True - ) + subprocess.run([cmake, "--build", str(build_dir), "-j", parallel], check=True) def _cuda_toolkit_version():