From 59802e0102b7d02f132cf3f758dc60ae7a23464f Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Fri, 12 Apr 2024 14:00:18 +0200 Subject: [PATCH] Fix mypy problem on Windows due to platform differences As reported in , mypy was failing on Windows due to an unnecessary type: ignore. This fixes it by ignoring the unused-ignore so that Windows is covered. --- pytensor/link/c/cmodule.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pytensor/link/c/cmodule.py b/pytensor/link/c/cmodule.py index 53c9bae8c4..99fc410719 100644 --- a/pytensor/link/c/cmodule.py +++ b/pytensor/link/c/cmodule.py @@ -284,7 +284,11 @@ def add_gcc_dll_directory() -> None: if (sys.platform == "win32") & (hasattr(os, "add_dll_directory")): gcc_path = shutil.which("gcc") if gcc_path is not None: - os.add_dll_directory(os.path.dirname(gcc_path)) # type: ignore + # Since add_dll_directory is only defined on windows, we need + # the ignore[attr-defined] on non-Windows platforms. + # For Windows we need ignore[unused-ignore] since the ignore + # is unnecessary with that platform. + os.add_dll_directory(os.path.dirname(gcc_path)) # type: ignore[attr-defined,unused-ignore] def dlimport(fullpath, suffix=None):