From cb7cd12d4eef8e41e236cd56c3332e9015c87434 Mon Sep 17 00:00:00 2001 From: Greyson LaLonde Date: Wed, 25 Mar 2026 13:44:57 +0800 Subject: [PATCH] fix: resolve mypy errors in crewai-files and add all packages to CI type checks --- .github/workflows/type-checker.yml | 2 +- lib/crewai-files/src/crewai_files/formatting/api.py | 4 ++-- lib/crewai-files/src/crewai_files/processing/constraints.py | 1 + lib/crewai-files/src/crewai_files/processing/transformers.py | 2 +- lib/crewai-files/src/crewai_files/processing/validators.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/type-checker.yml b/.github/workflows/type-checker.yml index e56214d89..3dd77187f 100644 --- a/.github/workflows/type-checker.yml +++ b/.github/workflows/type-checker.yml @@ -41,7 +41,7 @@ jobs: run: uv sync --all-groups --all-extras - name: Run type checks - run: uv run mypy lib/crewai/src/crewai/ lib/crewai-tools/src/crewai_tools/ + run: uv run mypy lib/ - name: Save uv caches if: steps.cache-restore.outputs.cache-hit != 'true' diff --git a/lib/crewai-files/src/crewai_files/formatting/api.py b/lib/crewai-files/src/crewai_files/formatting/api.py index 3c362315e..1d846b18a 100644 --- a/lib/crewai-files/src/crewai_files/formatting/api.py +++ b/lib/crewai-files/src/crewai_files/formatting/api.py @@ -122,7 +122,7 @@ def format_multimodal_content( return content_blocks # Use API-specific constraints for OpenAI - constraints_key = provider_type + constraints_key: str = provider_type if api == "responses" and "openai" in provider_type.lower(): constraints_key = "openai_responses" @@ -187,7 +187,7 @@ async def aformat_multimodal_content( return content_blocks # Use API-specific constraints for OpenAI - constraints_key = provider_type + constraints_key: str = provider_type if api == "responses" and "openai" in provider_type.lower(): constraints_key = "openai_responses" diff --git a/lib/crewai-files/src/crewai_files/processing/constraints.py b/lib/crewai-files/src/crewai_files/processing/constraints.py index fe11fe9b3..ba05827d5 100644 --- a/lib/crewai-files/src/crewai_files/processing/constraints.py +++ b/lib/crewai-files/src/crewai_files/processing/constraints.py @@ -15,6 +15,7 @@ from crewai_files.core.types import ( ProviderName = Literal[ "anthropic", "openai", + "openai_responses", "gemini", "bedrock", "azure", diff --git a/lib/crewai-files/src/crewai_files/processing/transformers.py b/lib/crewai-files/src/crewai_files/processing/transformers.py index a51f13c92..dc89ad015 100644 --- a/lib/crewai-files/src/crewai_files/processing/transformers.py +++ b/lib/crewai-files/src/crewai_files/processing/transformers.py @@ -120,7 +120,7 @@ def optimize_image( with Image.open(io.BytesIO(content)) as img: if img.mode in ("RGBA", "LA", "P"): - img = img.convert("RGB") + img = img.convert("RGB") # type: ignore[assignment] output_format = "JPEG" else: output_format = img.format or "JPEG" diff --git a/lib/crewai-files/src/crewai_files/processing/validators.py b/lib/crewai-files/src/crewai_files/processing/validators.py index 9f2c94e92..7710e36d5 100644 --- a/lib/crewai-files/src/crewai_files/processing/validators.py +++ b/lib/crewai-files/src/crewai_files/processing/validators.py @@ -85,7 +85,7 @@ def _get_audio_duration(content: bytes, filename: str | None = None) -> float | Duration in seconds or None if tinytag unavailable. """ try: - from tinytag import TinyTag # type: ignore[import-untyped] + from tinytag import TinyTag except ImportError: logger.warning( "tinytag not installed - cannot validate audio duration. "