Type-clean EventQueue successor: abstract base makes EventQueue() unusable for mypy users · Issue #1064 · a2aproject/a2a-python · GitHub
Skip to content

Type-clean EventQueue successor: abstract base makes EventQueue() unusable for mypy users #1064

Description

@bokelley

Problem

PR #944 split EventQueue into an abstract base + concrete EventQueueLegacy, with EventQueue.__new__ redirecting EventQueue(...) to EventQueueLegacy(...) at runtime for backwards compatibility. The docstring of EventQueue shows queue = EventQueue() as typical usage.

However, mypy correctly flags this pattern as an error because EventQueue is declared abstract via ABC + @abstractmethod on enqueue_event:

error: Cannot instantiate abstract class "EventQueue" with abstract attribute "enqueue_event"  [abstract]
error: "EventQueue" has no attribute "dequeue_event"; maybe "enqueue_event"?  [attr-defined]

The methods dequeue_event, tap, close, task_done, is_closed only exist on EventQueueLegacy, not on the abstract EventQueue interface.

Result: downstream type-checked codebases (we ship a Python SDK that strict-mode-mypys every commit across 3.10–3.13) must keep importing EventQueueLegacy explicitly — the class name advertises its own deprecation, but it remains the only typeable option in a2a-sdk 1.0.1.

a2a-sdk 1.0.1 internal usage

Even a2a-sdk's own modules never instantiate EventQueue() — they all use EventQueueLegacy():

  • a2a/server/events/in_memory_queue_manager.py: queue = EventQueueLegacy()
  • a2a/server/events/queue_manager.py: typed as EventQueueLegacy
  • a2a/server/events/event_consumer.py: typed as EventQueueLegacy
  • a2a/server/request_handlers/default_request_handler.py: queue = EventQueueLegacy()

Only the docstring of EventQueue itself shows queue = EventQueue().

Requested

One of:

  1. Promote EventQueue to a concrete (non-abstract) class that owns the full method surface (dequeue_event, tap, close, task_done, is_closed), making EventQueueLegacy a thin alias for the deprecation window.
  2. Add a DefaultEventQueue (or similar) concrete class that downstream users can import and instantiate without the *Legacy name, with the same method surface as EventQueueLegacy.
  3. Document that EventQueueLegacy is the supported instantiation surface for the foreseeable future and update the EventQueue docstring's queue = EventQueue() example accordingly so users (and type-checkers) aren't misled.

We don't have a preference on which path — any of the three unblocks the rename downstream.

Downstream tracking

adcontextprotocol/adcp-client-python#699 (left a TODO in our harness pointing at this issue).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: serverIssues related to frameworks for agent execution, HTTP/event handling, database persistence logic.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions