From abe9b147e1673708bf581fe92d9bf7cef26c7429 Mon Sep 17 00:00:00 2001 From: dpcollins-google <40498610+dpcollins-google@users.noreply.github.com> Date: Wed, 5 May 2021 14:10:09 -0400 Subject: [PATCH] fix: Remove Future type hint from return type which fails to type check when overridden (#133) --- .../cloudpubsub/internal/multiplexed_publisher_client.py | 2 +- .../cloud/pubsublite/cloudpubsub/internal/publisher_impl.py | 2 +- google/cloud/pubsublite/cloudpubsub/publisher_client.py | 2 +- .../pubsublite/cloudpubsub/publisher_client_interface.py | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/google/cloud/pubsublite/cloudpubsub/internal/multiplexed_publisher_client.py b/google/cloud/pubsublite/cloudpubsub/internal/multiplexed_publisher_client.py index 4bfe9cf5..249463c6 100644 --- a/google/cloud/pubsublite/cloudpubsub/internal/multiplexed_publisher_client.py +++ b/google/cloud/pubsublite/cloudpubsub/internal/multiplexed_publisher_client.py @@ -47,7 +47,7 @@ def publish( data: bytes, ordering_key: str = "", **attrs: Mapping[str, str] - ) -> "Future[str]": + ) -> Future: if isinstance(topic, str): topic = TopicPath.parse(topic) publisher = self._multiplexer.get_or_create( diff --git a/google/cloud/pubsublite/cloudpubsub/internal/publisher_impl.py b/google/cloud/pubsublite/cloudpubsub/internal/publisher_impl.py index 7f25e77d..2e66a380 100644 --- a/google/cloud/pubsublite/cloudpubsub/internal/publisher_impl.py +++ b/google/cloud/pubsublite/cloudpubsub/internal/publisher_impl.py @@ -35,7 +35,7 @@ def __init__(self, underlying: AsyncSinglePublisher): def publish( self, data: bytes, ordering_key: str = "", **attrs: Mapping[str, str] - ) -> "Future[str]": + ) -> Future: return self._managed_loop.submit( self._underlying.publish(data=data, ordering_key=ordering_key, **attrs) ) diff --git a/google/cloud/pubsublite/cloudpubsub/publisher_client.py b/google/cloud/pubsublite/cloudpubsub/publisher_client.py index 9ddd4da5..7a984ff9 100644 --- a/google/cloud/pubsublite/cloudpubsub/publisher_client.py +++ b/google/cloud/pubsublite/cloudpubsub/publisher_client.py @@ -94,7 +94,7 @@ def publish( data: bytes, ordering_key: str = "", **attrs: Mapping[str, str] - ) -> "Future[str]": + ) -> Future: self._require_stared.require_started() return self._impl.publish( topic=topic, data=data, ordering_key=ordering_key, **attrs diff --git a/google/cloud/pubsublite/cloudpubsub/publisher_client_interface.py b/google/cloud/pubsublite/cloudpubsub/publisher_client_interface.py index 5d15a601..6499b407 100644 --- a/google/cloud/pubsublite/cloudpubsub/publisher_client_interface.py +++ b/google/cloud/pubsublite/cloudpubsub/publisher_client_interface.py @@ -67,7 +67,7 @@ def publish( data: bytes, ordering_key: str = "", **attrs: Mapping[str, str], - ) -> "Future[str]": + ) -> Future: """ Publish a message. @@ -78,7 +78,8 @@ def publish( **attrs: Additional attributes to send. Returns: - A future completed with an ack id, which can be decoded using MessageMetadata.decode. + A future completed with an ack id of type str, which can be decoded using + MessageMetadata.decode. Raises: GoogleApiCallError: On a permanent failure.