From 9c0a80981bf9ef97495a9093291b89083fb2e4ab Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Tue, 10 Nov 2026 16:07:12 +0100 Subject: [PATCH] Check sys.platform before os.add_dll_directory pyrefly narrows os on sys.platform but not on platform.system(), so it warned that os.add_dll_directory does not exist when checking on Linux. Both are true on the same platforms. Co-Authored-By: Claude Opus 5.5 --- mikecore/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mikecore/__init__.py b/mikecore/__init__.py index d7f9a9f..3f2ae23 100644 --- a/mikecore/__init__.py +++ b/mikecore/__init__.py @@ -41,10 +41,11 @@ eumDLL.libfilepath = mikebin # Only while loading: the DLLs resolve their imports here and load nothing by -# name later. +# name later. sys.platform, not platform.system(), so type checkers know +# os.add_dll_directory exists here. _dll_dir = ( os.add_dll_directory(mikebin) - if platform.system() == "Windows" + if sys.platform == "win32" else contextlib.nullcontext() ) with _dll_dir: