Repository navigation
Keep kitty graphics platform check reachable for mypy on win32 - #15419
cristianchiriac wants to merge 3 commits 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.
|
Note: the remaining red check here, |
|
Hi, my PR is also working on |
|
Merged |
|
The two remaining red jobs are |
|
This has been fixed in a different way, but thanks for this PR. Closing for now. |
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.