Skip to content

Check sys.platform before os.add_dll_directory - #86

Merged
ryan-kipawa merged 1 commit into
masterfrom
fix/add-dll-directory-warning
Nov 11, 2026
Merged

ryan-kipawa merged 1 commit into
masterfrom
fix/add-dll-directory-warning

Conversation

@ryan-kipawa

Copy link
Copy Markdown
Collaborator

Summary

#64 added a warning in mikecore/__init__.py, and this PR removes it. The narrowing check changes from platform.system() to sys.platform. pyrefly understands sys.platform checks, so it knows os.add_dll_directory exists in that branch. Both checks are true on the same platforms.

 _dll_dir = (
     os.add_dll_directory(mikebin)
-    if platform.system() == "Windows"
+    if sys.platform == "win32"
     else contextlib.nullcontext()
 )

Evidence

Run on Linux with Python 3.11 and pyrefly 1.3.2, the same as CI:

  • Before (master, cb002bc): 329 warnings, including
    mikecore/__init__.py missing-attribute No attribute 'add_dll_directory' in module 'os'
    After (9c0a809): 328 warnings, and that one is gone. 0 errors.
  • uv run pytest -q: 184 passed, 1 skipped, 8 xfailed, which is the same as master.

MAX_WARNINGS stays at 330. #76 changes the same line, so lowering it here would cause a merge conflict.

Merge Danger

Door: two-way

Blast Radius: none

The Windows DLL directory is still added on Windows only, and Linux still gets nullcontext().

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@ryan-kipawa
ryan-kipawa merged commit 90a6d03 into master Nov 11, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant