Repository navigation
Keep kitty graphics platform check reachable for mypy on win32 - #15419
Open
cristianchiriac wants to merge 1 commit into
Open
cristianchiriac wants to merge 1 commit into
cristianchiriac wants to merge 1 commit into
Conversation
mypy 2.4 evaluates "sys.platform not in (...)" against the target platform. With --platform win32 it treats the early return in _supports_kitty_graphics as always taken and reports the rest of the function as unreachable, which fails the "Run MyPy" workflow (warn_unreachable is enabled) on every PR. Compare a local copy of sys.platform so the check stays a runtime check.
Author
|
Note: the remaining red check here, |
|
Hi, my PR is also working on |
This branch has not been deployed
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.
The Run MyPy workflow currently fails on every new PR (e.g. #15414, #15416, #15417), on both the ubuntu job (in the
--platform win32step) and the windows job:With mypy 2.4,
if sys.platform not in ("darwin", "linux"): return Falsein_supports_kitty_graphics()is evaluated against the target platform. Under--platform win32the early return is always taken, so everything after it is reported as unreachable (warn_unreachable = true). A# type: ignore[unreachable]wouldn't help, becausewarn_unused_ignores = truewould then fail on linux/darwin.This change compares a local copy of
sys.platform, so mypy treats it as an ordinary runtime check on all platforms. Behavior is unchanged, and tests that monkeypatchsys.platformstill work because the value is read on each call.Testing (mypy 2.4.0, project config):
mypy IPythonandmypy --platform linux|darwin|win32 IPythonall report "no issues found". Before the change,--platform win32reported the error above.pytest tests/test_kitty.py: 18 passed, 1 skipped.