Skip to content

Commit

Permalink
fix: Change type hint on callback to be Callback. (#135)
Browse files Browse the repository at this point in the history
The overrides library doesn't like the Callable type and breaks.

mkorpela/overrides#78
  • Loading branch information
dpcollins-google committed May 5, 2021
1 parent 75731f0 commit cbf16f8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
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

0 comments on commit cbf16f8

Please sign in to comment.