From f5331f3a4672a683efb470141c5979cafac1ab22 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 16:34:47 +0000 Subject: [PATCH] Fix lint: remove unused imports, fix E402 noqa, add type: ignore annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: João --- lib/crewai/src/crewai/a2a/_compat.py | 4 +++- .../src/crewai/a2a/extensions/registry.py | 2 -- lib/crewai/src/crewai/a2a/task_helpers.py | 10 -------- .../src/crewai/a2a/updates/polling/handler.py | 7 +----- .../a2a/updates/push_notifications/handler.py | 8 +------ .../crewai/a2a/updates/streaming/handler.py | 8 ------- lib/crewai/src/crewai/a2a/utils/agent_card.py | 9 ++++--- lib/crewai/src/crewai/a2a/utils/delegation.py | 9 ++----- lib/crewai/src/crewai/a2a/utils/task.py | 24 +++++++++---------- lib/crewai/src/crewai/a2a/wrapper.py | 1 - 10 files changed, 24 insertions(+), 58 deletions(-) diff --git a/lib/crewai/src/crewai/a2a/_compat.py b/lib/crewai/src/crewai/a2a/_compat.py index 927004b89..779e320c7 100644 --- a/lib/crewai/src/crewai/a2a/_compat.py +++ b/lib/crewai/src/crewai/a2a/_compat.py @@ -78,7 +78,9 @@ ROLE_AGENT = Role.ROLE_AGENT # Protobuf objects don't have model_dump() / model_copy(). # --------------------------------------------------------------------------- -from google.protobuf.json_format import MessageToDict # type: ignore[import-untyped] # noqa: E402 +from google.protobuf.json_format import ( # noqa: E402 + MessageToDict, +) def proto_to_json(msg: Any) -> str: diff --git a/lib/crewai/src/crewai/a2a/extensions/registry.py b/lib/crewai/src/crewai/a2a/extensions/registry.py index 2fc328f69..803a01f05 100644 --- a/lib/crewai/src/crewai/a2a/extensions/registry.py +++ b/lib/crewai/src/crewai/a2a/extensions/registry.py @@ -10,8 +10,6 @@ See: https://a2a-protocol.org/latest/topics/extensions/ from __future__ import annotations -from typing import Any - from a2a.client.interceptors import BeforeArgs, ClientCallInterceptor from a2a.extensions.common import ( HTTP_EXTENSION_HEADER, diff --git a/lib/crewai/src/crewai/a2a/task_helpers.py b/lib/crewai/src/crewai/a2a/task_helpers.py index 2d6e8750f..ca33b142c 100644 --- a/lib/crewai/src/crewai/a2a/task_helpers.py +++ b/lib/crewai/src/crewai/a2a/task_helpers.py @@ -4,19 +4,12 @@ from __future__ import annotations from collections.abc import AsyncIterator from typing import TYPE_CHECKING, Any -import uuid from a2a.client.errors import A2AClientError from a2a.types import ( AgentCard, Message, - Part, - Role, StreamResponse, - Task, - TaskArtifactUpdateEvent, - TaskState, - TaskStatusUpdateEvent, ) from typing_extensions import NotRequired, TypedDict @@ -31,12 +24,9 @@ from crewai.a2a._compat import ( TASK_STATE_SUBMITTED, TASK_STATE_WORKING, agent_card_to_dict, - is_stream_artifact_update, is_stream_message, - is_stream_status_update, is_stream_task, new_text_message, - new_text_part, part_is_text, part_text, ) diff --git a/lib/crewai/src/crewai/a2a/updates/polling/handler.py b/lib/crewai/src/crewai/a2a/updates/polling/handler.py index 36a501471..b9741a1b3 100644 --- a/lib/crewai/src/crewai/a2a/updates/polling/handler.py +++ b/lib/crewai/src/crewai/a2a/updates/polling/handler.py @@ -5,7 +5,6 @@ from __future__ import annotations import asyncio import time from typing import TYPE_CHECKING, Any -import uuid from a2a.client import Client from a2a.client.errors import A2AClientError @@ -13,18 +12,14 @@ from a2a.types import ( AgentCard, GetTaskRequest, Message, - Part, - Role, - TaskState, ) +from typing_extensions import Unpack from crewai.a2a._compat import ( ROLE_AGENT, TASK_STATE_FAILED, new_text_message, ) -from typing_extensions import Unpack - from crewai.a2a.errors import A2APollingTimeoutError from crewai.a2a.task_helpers import ( ACTIONABLE_STATES, diff --git a/lib/crewai/src/crewai/a2a/updates/push_notifications/handler.py b/lib/crewai/src/crewai/a2a/updates/push_notifications/handler.py index fce4fcc3f..2424a95cb 100644 --- a/lib/crewai/src/crewai/a2a/updates/push_notifications/handler.py +++ b/lib/crewai/src/crewai/a2a/updates/push_notifications/handler.py @@ -4,26 +4,20 @@ from __future__ import annotations import logging from typing import TYPE_CHECKING, Any -import uuid from a2a.client import Client from a2a.client.errors import A2AClientError from a2a.types import ( AgentCard, Message, - Part, - Role, - TaskState, ) +from typing_extensions import Unpack from crewai.a2a._compat import ( ROLE_AGENT, TASK_STATE_FAILED, new_text_message, - new_text_part, ) -from typing_extensions import Unpack - from crewai.a2a.task_helpers import ( TaskStateResult, process_task_state, diff --git a/lib/crewai/src/crewai/a2a/updates/streaming/handler.py b/lib/crewai/src/crewai/a2a/updates/streaming/handler.py index 7aef6486c..2a2026e16 100644 --- a/lib/crewai/src/crewai/a2a/updates/streaming/handler.py +++ b/lib/crewai/src/crewai/a2a/updates/streaming/handler.py @@ -5,7 +5,6 @@ from __future__ import annotations import asyncio import logging from typing import Final -import uuid from a2a.client import Client from a2a.client.errors import A2AClientError @@ -13,22 +12,15 @@ from a2a.types import ( AgentCard, GetTaskRequest, Message, - Part, - Role, - StreamResponse, SubscribeToTaskRequest, Task, TaskArtifactUpdateEvent, - TaskState, - TaskStatusUpdateEvent, ) from typing_extensions import Unpack from crewai.a2a._compat import ( ROLE_AGENT, TASK_STATE_FAILED, - agent_card_to_dict, - is_status_update_final, is_stream_artifact_update, is_stream_message, is_stream_status_update, diff --git a/lib/crewai/src/crewai/a2a/utils/agent_card.py b/lib/crewai/src/crewai/a2a/utils/agent_card.py index 69ef28c4b..dcc1a77b9 100644 --- a/lib/crewai/src/crewai/a2a/utils/agent_card.py +++ b/lib/crewai/src/crewai/a2a/utils/agent_card.py @@ -14,13 +14,16 @@ from typing import TYPE_CHECKING from a2a.client.errors import A2AClientError from a2a.types import AgentCapabilities, AgentCard, AgentInterface, AgentSkill -from google.protobuf.json_format import ParseDict # type: ignore[import-untyped] - -from crewai.a2a._compat import agent_card_to_dict, agent_card_protocol_version, proto_copy 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] import httpx +from crewai.a2a._compat import ( + agent_card_protocol_version, + agent_card_to_dict, + proto_copy, +) from crewai.a2a.auth.client_schemes import APIKeyAuth, HTTPDigestAuth from crewai.a2a.auth.utils import ( _auth_store, diff --git a/lib/crewai/src/crewai/a2a/utils/delegation.py b/lib/crewai/src/crewai/a2a/utils/delegation.py index e2dcfed53..9c598be21 100644 --- a/lib/crewai/src/crewai/a2a/utils/delegation.py +++ b/lib/crewai/src/crewai/a2a/utils/delegation.py @@ -3,7 +3,6 @@ from __future__ import annotations import asyncio -import base64 from collections.abc import AsyncIterator, Callable, MutableMapping import concurrent.futures from contextlib import asynccontextmanager @@ -12,7 +11,7 @@ import logging from typing import TYPE_CHECKING, Any, Final, Literal import uuid -from a2a.client import Client, ClientConfig, ClientFactory +from a2a.client import Client, ClientFactory from a2a.types import ( AgentCard, Message, @@ -21,11 +20,11 @@ from a2a.types import ( TaskPushNotificationConfig, ) import httpx +from pydantic import BaseModel from crewai.a2a._compat import ( ROLE_USER, agent_card_interfaces, - agent_card_preferred_transport, agent_card_protocol_version, agent_card_to_dict, agent_card_url, @@ -33,8 +32,6 @@ from crewai.a2a._compat import ( new_text_part, proto_copy, ) -from pydantic import BaseModel - from crewai.a2a.auth.client_schemes import APIKeyAuth, HTTPDigestAuth from crewai.a2a.auth.utils import ( _auth_store, @@ -50,8 +47,6 @@ from crewai.a2a.task_helpers import TaskStateResult from crewai.a2a.types import ( HANDLER_REGISTRY, HandlerType, - PartsDict, - PartsMetadataDict, TransportType, ) from crewai.a2a.updates import ( diff --git a/lib/crewai/src/crewai/a2a/utils/task.py b/lib/crewai/src/crewai/a2a/utils/task.py index f97e2b231..3b711564c 100644 --- a/lib/crewai/src/crewai/a2a/utils/task.py +++ b/lib/crewai/src/crewai/a2a/utils/task.py @@ -13,11 +13,15 @@ import os from typing import TYPE_CHECKING, Any, ParamSpec, TypeVar, cast from urllib.parse import urlparse +from a2a.helpers.proto_helpers import ( + new_data_artifact, + new_text_artifact, + new_text_message as new_agent_text_message, +) from a2a.server.agent_execution import RequestContext from a2a.server.events import EventQueue from a2a.types import ( Artifact, - InternalError, InvalidParamsError, Message, Part, @@ -26,28 +30,20 @@ from a2a.types import ( TaskStatus, TaskStatusUpdateEvent, ) -from a2a.helpers.proto_helpers import ( - new_data_artifact, - new_text_artifact, - new_text_message as new_agent_text_message, -) from a2a.utils.errors import A2AError as ServerError +from aiocache import SimpleMemoryCache, caches # type: ignore[import-untyped] +from pydantic import BaseModel +from typing_extensions import TypedDict from crewai.a2a._compat import ( - ROLE_AGENT, TASK_STATE_CANCELED, TASK_STATE_COMPLETED, TASK_STATE_FAILED, part_has_data, part_has_file, part_is_text, - part_text, proto_copy, ) -from aiocache import SimpleMemoryCache, caches # type: ignore[import-untyped] -from pydantic import BaseModel -from typing_extensions import TypedDict - from crewai.a2a.utils.agent_card import _get_server_config from crewai.a2a.utils.content_type import validate_message_parts from crewai.events.event_bus import crewai_event_bus @@ -81,7 +77,9 @@ 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, # type: ignore[import-untyped] + ) val = MessageToDict(part.data) if isinstance(val, dict): diff --git a/lib/crewai/src/crewai/a2a/wrapper.py b/lib/crewai/src/crewai/a2a/wrapper.py index f01e8a7b8..36c41bb14 100644 --- a/lib/crewai/src/crewai/a2a/wrapper.py +++ b/lib/crewai/src/crewai/a2a/wrapper.py @@ -14,7 +14,6 @@ import json from types import MethodType from typing import TYPE_CHECKING, Any, NamedTuple -from a2a.types import Role, TaskState from pydantic import BaseModel, ValidationError from crewai.a2a._compat import (