The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
chore(windows-footguns): flag module-level imports of POSIX-only stdlib modules
teknium11772c6fb77ab
diff --git a/scripts/check-windows-footguns.py b/scripts/check-windows-footguns.pyindex 30100402d0a..d5de92b410c 100644--- a/scripts/check-windows-footguns.py+++ b/scripts/check-windows-footguns.py@@ -431,6 +431,27 @@ FOOTGUNS: list[Footgun] = [and _call_closes_on_line(line, m.end())),),+ Footgun(+ name="module-level import of a POSIX-only stdlib module",+ # Only unindented imports: a top-level `import fcntl` fails at import time on Windows and takes+ # every importer down with it (tools.bot_desktop.lease took computer_use down on native+ # Windows). Indented imports inside a function or a try/except ImportError are the fix shape.+ pattern=re.compile(+ r"^(?:import\s+(?:fcntl|pwd|grp|termios|resource|pty|tty)\b"+ r"|from\s+(?:fcntl|pwd|grp|termios|resource|pty|tty)\s+import\b)"+ ),+ message=(+ "fcntl/pwd/grp/termios/resource/pty/tty do not exist on Windows; a module-level import "+ "raises ModuleNotFoundError and breaks every module that imports this one."+ ),+ fix=(+ "Import lazily inside the function that needs it, or\n"+ "try:\n"+ " import fcntl\n"+ "except ImportError:\n"+ " fcntl = None # and take the Windows path when None"+ ),+ ),]