Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change type hint on callback to be Callback. #135

Merged
merged 1 commit into from May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from concurrent.futures.thread import ThreadPoolExecutor
from typing import Union, Optional, Set
from typing import Union, Optional, Set, Callable, cast

from google.cloud.pubsub_v1.subscriber.futures import StreamingPullFuture

Expand Down Expand Up @@ -61,12 +61,13 @@ def cancel_streaming_pull_future(fut: StreamingPullFuture):
def subscribe(
self,
subscription: Union[SubscriptionPath, str],
callback: MessageCallback,
callback: Callable, # TODO(dpcollins): Change to MessageCallback,
per_partition_flow_control_settings: FlowControlSettings,
fixed_partitions: Optional[Set[Partition]] = None,
) -> StreamingPullFuture:
if isinstance(subscription, str):
subscription = SubscriptionPath.parse(subscription)
callback = cast(MessageCallback, callback)

def create_and_open():
underlying = self._underlying_factory(
Expand Down
5 changes: 2 additions & 3 deletions google/cloud/pubsublite/cloudpubsub/subscriber_client.py
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from concurrent.futures.thread import ThreadPoolExecutor
from typing import Optional, Union, Set, AsyncIterator
from typing import Optional, Union, Set, AsyncIterator, Callable

from google.api_core.client_options import ClientOptions
from google.auth.credentials import Credentials
Expand All @@ -33,7 +33,6 @@
from google.cloud.pubsublite.cloudpubsub.nack_handler import NackHandler
from google.cloud.pubsublite.cloudpubsub.subscriber_client_interface import (
SubscriberClientInterface,
MessageCallback,
AsyncSubscriberClientInterface,
)
from google.cloud.pubsublite.internal.constructable_from_service_account import (
Expand Down Expand Up @@ -100,7 +99,7 @@ def __init__(
def subscribe(
self,
subscription: Union[SubscriptionPath, str],
callback: MessageCallback,
callback: Callable, # TODO(dpcollins): Change to MessageCallback,
per_partition_flow_control_settings: FlowControlSettings,
fixed_partitions: Optional[Set[Partition]] = None,
) -> StreamingPullFuture:
Expand Down
Expand Up @@ -81,7 +81,7 @@ class SubscriberClientInterface(ContextManager):
def subscribe(
self,
subscription: Union[SubscriptionPath, str],
callback: MessageCallback,
callback: Callable, # TODO(dpcollins): Change to MessageCallback,
per_partition_flow_control_settings: FlowControlSettings,
fixed_partitions: Optional[Set[Partition]] = None,
) -> StreamingPullFuture:
Expand Down