diff --git a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_linux.py b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_linux.py index 5552b2296f4..4a6d0c75cae 100644 --- a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_linux.py +++ b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_linux.py @@ -188,7 +188,7 @@ def load_with_system_search(desc: LibDescriptor) -> LoadedDL | None: return None -def _preload_nvrtc_builtins(found_path: str, found_via: str | None) -> None: +def _preload_nvrtc_builtins(found_path: str, found_via: str) -> None: # Let Conda packaging provide sibling lookup through RPATH. if found_via == FOUND_VIA_CONDA: return @@ -224,7 +224,7 @@ def _preload_nvrtc_builtins(found_path: str, found_via: str | None) -> None: ) -def load_with_abs_path(desc: LibDescriptor, found_path: str, found_via: str | None = None) -> LoadedDL: +def load_with_abs_path(desc: LibDescriptor, found_path: str, found_via: str) -> LoadedDL: """Load a dynamic library from the given path. Args: diff --git a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_windows.py b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_windows.py index 6e7220a19e7..79e3f4a946b 100644 --- a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_windows.py +++ b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/load_dl_windows.py @@ -161,7 +161,7 @@ def load_with_system_search(desc: LibDescriptor) -> LoadedDL | None: return None -def load_with_abs_path(desc: LibDescriptor, found_path: str, found_via: str | None = None) -> LoadedDL: +def load_with_abs_path(desc: LibDescriptor, found_path: str, found_via: str) -> LoadedDL: """Load a dynamic library from the given path. Args: diff --git a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/platform_loader.py b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/platform_loader.py index 283578fcfa8..ab0c881aa08 100644 --- a/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/platform_loader.py +++ b/cuda_pathfinder/cuda/pathfinder/_dynamic_libs/platform_loader.py @@ -28,7 +28,7 @@ def check_if_already_loaded_from_elsewhere(self, desc: LibDescriptor) -> LoadedD def load_with_system_search(self, desc: LibDescriptor) -> LoadedDL | None: ... - def load_with_abs_path(self, desc: LibDescriptor, found_path: str, found_via: str | None = None) -> LoadedDL: ... + def load_with_abs_path(self, desc: LibDescriptor, found_path: str, found_via: str) -> LoadedDL: ... if sys.platform == "win32": diff --git a/cuda_pathfinder/cuda/pathfinder/_headers/header_descriptor.py b/cuda_pathfinder/cuda/pathfinder/_headers/header_descriptor.py index 3b108f618a5..7a0c2d9f079 100644 --- a/cuda_pathfinder/cuda/pathfinder/_headers/header_descriptor.py +++ b/cuda_pathfinder/cuda/pathfinder/_headers/header_descriptor.py @@ -13,7 +13,7 @@ import glob import os import sysconfig -from typing import TypeAlias, cast +from typing import TypeAlias from cuda.pathfinder._headers.header_descriptor_catalog import ( HEADER_DESCRIPTOR_CATALOG, @@ -34,8 +34,8 @@ def platform_include_subdirs(desc: HeaderDescriptor) -> tuple[str, ...]: common subdirs. On Linux, only the common subdirs are returned. """ if IS_WINDOWS: - return cast(tuple[str, ...], desc.include_subdirs_windows + desc.include_subdirs) - return cast(tuple[str, ...], desc.include_subdirs) + return desc.include_subdirs_windows + desc.include_subdirs + return desc.include_subdirs def system_install_dir_patterns(desc: HeaderDescriptor) -> tuple[str, ...]: diff --git a/cuda_pathfinder/cuda/pathfinder/_utils/driver_info.py b/cuda_pathfinder/cuda/pathfinder/_utils/driver_info.py index d07c4b861d3..95a392abebe 100644 --- a/cuda_pathfinder/cuda/pathfinder/_utils/driver_info.py +++ b/cuda_pathfinder/cuda/pathfinder/_utils/driver_info.py @@ -69,7 +69,8 @@ def query_driver_cuda_version() -> DriverCudaVersion: def _query_driver_cuda_version_int() -> int: """Return the encoded CUDA driver version from ``cuDriverGetVersion()``.""" loaded_cuda = _load_nvidia_dynamic_lib("cuda") - driver_lib = _DRIVER_LIB_LOADER(loaded_cuda.abs_path) + # `LoadedDL.abs_path` is typed `str | None`, but the Windows loader is declared to take `str`. + driver_lib = _DRIVER_LIB_LOADER(loaded_cuda.abs_path) # type: ignore[arg-type, unused-ignore] cu_driver_get_version = driver_lib.cuDriverGetVersion cu_driver_get_version.argtypes = [ctypes.POINTER(ctypes.c_int)] cu_driver_get_version.restype = ctypes.c_int diff --git a/cuda_pathfinder/pyproject.toml b/cuda_pathfinder/pyproject.toml index 904463b7022..bb62faae7a6 100644 --- a/cuda_pathfinder/pyproject.toml +++ b/cuda_pathfinder/pyproject.toml @@ -129,6 +129,9 @@ markers = [ # Basic settings python_version = "3.11" explicit_package_bases = true +# Resolve `cuda.pathfinder` imports from this directory whatever the working +# directory is. Without it the package's own imports are typed as `Any`. +mypy_path = "$MYPY_CONFIG_FILE_DIR" warn_return_any = true warn_unused_configs = true disallow_untyped_defs = true