fix: use sys.platform guards so mypy passes on Windows - #7401
Conversation
mypy does not narrow on `platform.system()`, so Windows-based contributors get 8 spurious attr-defined/unused-ignore errors from the termios and resource imports. Switch to `sys.platform` comparisons, which mypy understands natively, and drop the now-unneeded type-ignore comments. Fixes crewAIInc#7400
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe PR updates platform checks in ChangesWindows platform checks
Suggested reviewers: Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The changes are limited to platform-aware guards and type-checking cleanup, with no identified runtime risk remaining. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
mypy does not narrow on `platform.system()`, so Windows-based contributors get 8 spurious attr-defined/unused-ignore errors from the termios and resource imports. Switch to `sys.platform` comparisons, which mypy understands natively, and drop the now-unneeded type-ignore comments. Fixes crewAIInc#7400 Co-authored-by: Vidit Ostwal <110953813+Vidit-Ostwal@users.noreply.github.com>
Fixes #7400
What
Two minimal changes so
mypypasses under Windows platform semantics. Runtime behavior is unchanged.lib/crewai/src/crewai/utilities/crew_chat.py: replaceplatform.system() == "Windows"withsys.platform == "win32", which mypy natively understands for branch pruning. The two# type: ignore[attr-defined]comments on themsvcrtcalls were flagged as unused under win32 semantics and are removed.import platformwas only used here and is dropped.lib/crewai/src/crewai/memory/storage/lancedb_storage.py: wrap the existing try/except aroundresourceinif sys.platform != "win32":so mypy skips it under win32 semantics. Runtime behavior is unchanged — theresourceimport already failed on Windows and was swallowed by theexcept.Verification
uv run mypy lib/crewai/src/crewai/on Windows: 8 errors → 0 (Success: no issues found in 515 source files)uv run mypy --platform linux lib/crewai/src/crewai/: still clean (no regression)uv run ruff check lib/: clean; pre-commit hooks passlib/crewai/tests/cli/test_crew_chat.py: 6 passedqdrant_edgeDLL load failures on this Windows machine, which also occur onmainand are unrelated to this changeThis PR was drafted with AI assistance (Claude Code) and should receive the
llm-generatedlabel per CONTRIBUTING.md.