From 509865fff21e7b6d390b19fe6b87be3758aabc5b Mon Sep 17 00:00:00 2001 From: Nathan Page Date: Sun, 9 May 2021 15:37:07 -0700 Subject: [PATCH] fix windows check --- rich/_windows.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rich/_windows.py b/rich/_windows.py index b1b07864..bac88e63 100644 --- a/rich/_windows.py +++ b/rich/_windows.py @@ -1,7 +1,6 @@ import sys from dataclasses import dataclass -from typing import Any @dataclass @@ -19,7 +18,11 @@ try: from ctypes import wintypes from ctypes import LibraryLoader - windll = LibraryLoader(ctypes.WinDLL) # type: ignore # expected to only work on windows + if sys.platform == "win32": + windll = LibraryLoader(ctypes.WinDLL) + else: + windll = None + raise ImportError("Not windows") except (AttributeError, ImportError, ValueError): # Fallback if we can't load the Windows DLL @@ -54,7 +57,7 @@ else: vt = bool(result and console_mode.value & ENABLE_VIRTUAL_TERMINAL_PROCESSING) truecolor = False if vt: - win_version = sys.getwindowsversion() # type: ignore # expected to only work on windows + win_version = sys.getwindowsversion() truecolor = win_version.major > 10 or ( win_version.major == 10 and win_version.build >= 15063 )