Skip to content

Commit c0b58e7

Browse files
committed
Guard the Windows console call with sys.platform
Switch the platform check from os.name to sys.platform so the type checker recognises the block as Windows-only and skips it on Linux, while keeping the direct ctypes.windll call the linter prefers. Lint and type check now both pass on every platform.
1 parent 21a540d commit c0b58e7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/sentineldeck/tui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def init_stream() -> None:
4949

5050

5151
def _enable_windows_vt() -> None:
52-
if os.name != "nt":
52+
if sys.platform != "win32": # sys.platform lets the type checker skip this on Linux
5353
return
5454
try:
5555
import ctypes
5656

57-
kernel32 = getattr(ctypes, "windll").kernel32 # windll is Windows-only
57+
kernel32 = ctypes.windll.kernel32
5858
for handle_id in (-11, -12): # STD_OUTPUT_HANDLE, STD_ERROR_HANDLE
5959
handle = kernel32.GetStdHandle(handle_id)
6060
mode = ctypes.c_uint32()

0 commit comments

Comments
 (0)