Skip to content

Commit ccf7d69

Browse files
committed
fix(ai): use getattr for ctypes.windll cross-platform mypy compliance
ctypes.windll is Windows-only; accessing it directly causes mypy [attr-defined] errors on Linux CI. Use getattr(ctypes, 'windll', None) with explicit None check instead of relying solely on try/except. No runtime behavior change — the AttributeError was already caught.
1 parent 728e4ae commit ccf7d69

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

plugins/sqlseed-ai/src/sqlseed_ai/_hardware.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ class MEMORYSTATUSEX(ctypes.Structure):
5151

5252
stat = MEMORYSTATUSEX()
5353
stat.dwLength = ctypes.sizeof(stat)
54-
ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
54+
# ctypes.windll only exists on Windows; use getattr for cross-platform safety
55+
windll = getattr(ctypes, "windll", None)
56+
if windll is None:
57+
return None
58+
windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
5559
return (
5660
round(stat.ullTotalPhys / (1024**3), 1),
5761
round(stat.ullAvailPhys / (1024**3), 1),

0 commit comments

Comments
 (0)