Remove all type: ignore comments to avoid unused-ignore on some Python versions

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2026-04-24 16:40:28 +00:00
parent f5331f3a46
commit 24d2d8dabb
5 changed files with 16 additions and 18 deletions

View File

@@ -31,7 +31,7 @@ from a2a.types import Part # noqa: E402
def part_is_text(part: Part) -> bool:
"""Return True when the Part carries text content."""
return part.HasField("text") # type: ignore[no-any-return]
return part.HasField("text")
def part_text(part: Part) -> str:
@@ -41,12 +41,12 @@ def part_text(part: Part) -> str:
def part_has_data(part: Part) -> bool:
"""Return True when the Part carries structured data."""
return part.HasField("data") # type: ignore[no-any-return]
return part.HasField("data")
def part_has_file(part: Part) -> bool:
"""Return True when the Part carries a file (url or raw bytes)."""
return part.HasField("url") or part.HasField("raw") # type: ignore[no-any-return]
return part.HasField("url") or part.HasField("raw")
# ---------------------------------------------------------------------------
@@ -90,7 +90,7 @@ def proto_to_json(msg: Any) -> str:
"""
from google.protobuf.json_format import MessageToJson
return MessageToJson(msg, preserving_proto_field_name=True, indent=2) # type: ignore[no-any-return]
return MessageToJson(msg, preserving_proto_field_name=True, indent=2)
def agent_card_to_dict(agent_card: Any, *, exclude_none: bool = True) -> dict[str, Any]:
@@ -98,7 +98,7 @@ def agent_card_to_dict(agent_card: Any, *, exclude_none: bool = True) -> dict[st
Works like ``agent_card.model_dump(exclude_none=True)`` did in v0.3.
"""
return MessageToDict( # type: ignore[no-any-return]
return MessageToDict(
agent_card,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=not exclude_none,
@@ -175,7 +175,7 @@ def agent_card_url(agent_card: AgentCard) -> str:
In v1.0 the URL lives inside ``supported_interfaces``.
"""
if agent_card.supported_interfaces:
return agent_card.supported_interfaces[0].url # type: ignore[no-any-return]
return agent_card.supported_interfaces[0].url
return ""
@@ -186,7 +186,7 @@ def agent_card_preferred_transport(agent_card: AgentCard) -> str:
In v1.0 it's the protocol_binding of the first supported_interface.
"""
if agent_card.supported_interfaces:
return agent_card.supported_interfaces[0].protocol_binding # type: ignore[no-any-return]
return agent_card.supported_interfaces[0].protocol_binding
return "JSONRPC"
@@ -226,22 +226,22 @@ from a2a.types import ( # noqa: E402
def is_stream_message(chunk: StreamResponse) -> bool:
"""Check if a StreamResponse contains a Message."""
return chunk.HasField("message") # type: ignore[no-any-return]
return chunk.HasField("message")
def is_stream_task(chunk: StreamResponse) -> bool:
"""Check if a StreamResponse contains a Task."""
return chunk.HasField("task") # type: ignore[no-any-return]
return chunk.HasField("task")
def is_stream_status_update(chunk: StreamResponse) -> bool:
"""Check if a StreamResponse contains a TaskStatusUpdateEvent."""
return chunk.HasField("status_update") # type: ignore[no-any-return]
return chunk.HasField("status_update")
def is_stream_artifact_update(chunk: StreamResponse) -> bool:
"""Check if a StreamResponse contains a TaskArtifactUpdateEvent."""
return chunk.HasField("artifact_update") # type: ignore[no-any-return]
return chunk.HasField("artifact_update")
# ---------------------------------------------------------------------------

View File

@@ -16,7 +16,7 @@ from a2a.client.errors import A2AClientError
from a2a.types import AgentCapabilities, AgentCard, AgentInterface, AgentSkill
from aiocache import cached # type: ignore[import-untyped]
from aiocache.serializers import PickleSerializer # type: ignore[import-untyped]
from google.protobuf.json_format import ParseDict # type: ignore[import-untyped]
from google.protobuf.json_format import ParseDict
import httpx
from crewai.a2a._compat import (
@@ -283,7 +283,7 @@ async def _afetch_agent_card_impl(
)
response.raise_for_status()
agent_card: AgentCard = ParseDict(response.json(), AgentCard()) # type: ignore[assignment]
agent_card = ParseDict(response.json(), AgentCard())
fetch_time_ms = (time.perf_counter() - start_time) * 1000
agent_card_dict = agent_card_to_dict(agent_card)

View File

@@ -18,7 +18,7 @@ import logging
from typing import Any, Literal
from a2a.types import AgentCard, AgentCardSignature
from google.protobuf.json_format import MessageToDict # type: ignore[import-untyped]
from google.protobuf.json_format import MessageToDict
import jwt
from pydantic import SecretStr

View File

@@ -324,7 +324,7 @@ async def aexecute_a2a_delegation(
turn_number=turn_number,
agent_branch=agent_branch,
agent_id=agent_id,
agent_role=agent_role, # type: ignore[arg-type]
agent_role=agent_role,
response_model=response_model,
updates=updates,
from_task=from_task,

View File

@@ -77,9 +77,7 @@ def _get_data_parts(parts: list[Part]) -> list[dict[str, Any]]:
result: list[dict[str, Any]] = []
for part in parts:
if part_has_data(part):
from google.protobuf.json_format import (
MessageToDict, # type: ignore[import-untyped]
)
from google.protobuf.json_format import MessageToDict
val = MessageToDict(part.data)
if isinstance(val, dict):