Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

fix: use sys.platform guards so mypy passes on Windows (#7401)

Modusensus7e80d94921dd
diff --git a/lib/crewai/src/crewai/memory/storage/lancedb_storage.py b/lib/crewai/src/crewai/memory/storage/lancedb_storage.py
index 8c9d640a5..6a97900fd 100644
--- a/lib/crewai/src/crewai/memory/storage/lancedb_storage.py
+++ b/lib/crewai/src/crewai/memory/storage/lancedb_storage.py
@@ -8,6 +8,7 @@ import json
import logging
import os
from pathlib import Path
+import sys
import threading
import time
from typing import Any
@@ -77,14 +78,15 @@ class LanceDBStorage:
self._table_name = table_name
self._db = lancedb.connect(str(self._path))
- try:
- import resource
+ if sys.platform != "win32":
+ try:
+ import resource
- soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
- if soft < 4096:
- resource.setrlimit(resource.RLIMIT_NOFILE, (min(hard, 4096), hard))
- except Exception: # noqa: S110
- pass # Windows or already at the max hard limit — safe to ignore
+ soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
+ if soft < 4096:
+ resource.setrlimit(resource.RLIMIT_NOFILE, (min(hard, 4096), hard))
+ except Exception: # noqa: S110
+ pass # Already at the max hard limit — safe to ignore
self._compact_every = compact_every
self._save_count = 0
diff --git a/lib/crewai/src/crewai/utilities/crew_chat.py b/lib/crewai/src/crewai/utilities/crew_chat.py
index 8fa5a685c..50d7ebc20 100644
--- a/lib/crewai/src/crewai/utilities/crew_chat.py
+++ b/lib/crewai/src/crewai/utilities/crew_chat.py
@@ -3,7 +3,6 @@
import contextvars
import json
from pathlib import Path
-import platform
import re
import sys
import threading
@@ -175,11 +174,11 @@ def create_tool_function(crew: Crew, messages: list[LLMMessage]) -> Any:
def flush_input() -> None:
"""Flush any pending input from the user."""
- if platform.system() == "Windows":
+ if sys.platform == "win32":
import msvcrt
- while msvcrt.kbhit(): # type: ignore[attr-defined]
- msvcrt.getch() # type: ignore[attr-defined]
+ while msvcrt.kbhit():
+ msvcrt.getch()
else:
import termios