queue: Fix ensure_queue type to accept a callback returning any object.

channel.basic_consume actually returns str.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-08-02 18:54:30 -07:00 committed by Tim Abbott
parent 5e355abe2e
commit f7e2426fc5
1 changed files with 3 additions and 3 deletions

View File

@ -102,7 +102,7 @@ class QueueClient(Generic[ChannelT], metaclass=ABCMeta):
return self.channel is not None
@abstractmethod
def ensure_queue(self, queue_name: str, callback: Callable[[ChannelT], None]) -> None:
def ensure_queue(self, queue_name: str, callback: Callable[[ChannelT], object]) -> None:
raise NotImplementedError
def publish(self, queue_name: str, body: bytes) -> None:
@ -147,7 +147,7 @@ class SimpleQueueClient(QueueClient[BlockingChannel]):
if self.connection is not None:
self.connection.close()
def ensure_queue(self, queue_name: str, callback: Callable[[BlockingChannel], None]) -> None:
def ensure_queue(self, queue_name: str, callback: Callable[[BlockingChannel], object]) -> None:
"""Ensure that a given queue has been declared, and then call
the callback with no arguments."""
if self.connection is None or not self.connection.is_open:
@ -320,7 +320,7 @@ class TornadoQueueClient(QueueClient[Channel]):
if self.connection is not None:
self.connection.close()
def ensure_queue(self, queue_name: str, callback: Callable[[Channel], None]) -> None:
def ensure_queue(self, queue_name: str, callback: Callable[[Channel], object]) -> None:
def finish(frame: Any) -> None:
assert self.channel is not None
self.queues.add(queue_name)