Repository navigation
Check sys.platform before os.add_dll_directory - #86
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#64 added a warning in
mikecore/__init__.py, and this PR removes it. The narrowing check changes fromplatform.system()tosys.platform. pyrefly understandssys.platformchecks, so it knowsos.add_dll_directoryexists 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:
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_WARNINGSstays 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