From e2576b6a6c81fbe610e7170bbfb45e22d7dd41db Mon Sep 17 00:00:00 2001 From: mukund-ananthu <83691193+mukund-ananthu@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:01:05 -0400 Subject: [PATCH] chore: Update mypy version (#1185) Co-authored-by: Owl Bot --- google/cloud/pubsub_v1/publisher/_batch/thread.py | 2 +- google/cloud/pubsub_v1/publisher/futures.py | 2 +- google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py | 4 ++-- .../pubsub_v1/subscriber/_protocol/streaming_pull_manager.py | 2 +- google/cloud/pubsub_v1/subscriber/futures.py | 2 +- google/cloud/pubsub_v1/subscriber/scheduler.py | 2 +- noxfile.py | 2 +- owlbot.py | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/google/cloud/pubsub_v1/publisher/_batch/thread.py b/google/cloud/pubsub_v1/publisher/_batch/thread.py index f6436fb7b..e6b8407fd 100644 --- a/google/cloud/pubsub_v1/publisher/_batch/thread.py +++ b/google/cloud/pubsub_v1/publisher/_batch/thread.py @@ -90,7 +90,7 @@ def __init__( client: "PublisherClient", topic: str, settings: "types.BatchSettings", - batch_done_callback: Callable[[bool], Any] = None, + batch_done_callback: Optional[Callable[[bool], Any]] = None, commit_when_full: bool = True, commit_retry: "OptionalRetry" = gapic_v1.method.DEFAULT, commit_timeout: "types.OptionalTimeout" = gapic_v1.method.DEFAULT, diff --git a/google/cloud/pubsub_v1/publisher/futures.py b/google/cloud/pubsub_v1/publisher/futures.py index c7cc66f18..7b5921673 100644 --- a/google/cloud/pubsub_v1/publisher/futures.py +++ b/google/cloud/pubsub_v1/publisher/futures.py @@ -45,7 +45,7 @@ def cancelled(self) -> bool: """ return False - def result(self, timeout: Union[int, float] = None) -> str: + def result(self, timeout: Union[int, float, None] = None) -> str: """Return the message ID or raise an exception. This blocks until the message has been published successfully and diff --git a/google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py b/google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py index fbcab781d..a7e18a88e 100644 --- a/google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py +++ b/google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py @@ -15,7 +15,7 @@ import logging import queue import time -from typing import Any, Callable, List, Sequence +from typing import Any, Callable, List, Sequence, Optional import uuid @@ -32,7 +32,7 @@ def _get_many( - queue_: queue.Queue, max_items: int = None, max_latency: float = 0 + queue_: queue.Queue, max_items: Optional[int] = None, max_latency: float = 0 ) -> List[Any]: """Get multiple items from a Queue. diff --git a/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py b/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py index f07db8546..b8531db17 100644 --- a/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py +++ b/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py @@ -267,7 +267,7 @@ def __init__( client: "subscriber.Client", subscription: str, flow_control: types.FlowControl = types.FlowControl(), - scheduler: ThreadScheduler = None, + scheduler: Optional[ThreadScheduler] = None, use_legacy_flow_control: bool = False, await_callbacks_on_shutdown: bool = False, ): diff --git a/google/cloud/pubsub_v1/subscriber/futures.py b/google/cloud/pubsub_v1/subscriber/futures.py index f043b7eb5..4c46c6813 100644 --- a/google/cloud/pubsub_v1/subscriber/futures.py +++ b/google/cloud/pubsub_v1/subscriber/futures.py @@ -104,7 +104,7 @@ def cancelled(self) -> bool: """ return False - def result(self, timeout: Union[int, float] = None) -> AcknowledgeStatus: + def result(self, timeout: Union[int, float, None] = None) -> AcknowledgeStatus: """Return a success code or raise an exception. This blocks until the operation completes successfully and diff --git a/google/cloud/pubsub_v1/subscriber/scheduler.py b/google/cloud/pubsub_v1/subscriber/scheduler.py index ca270a077..a3b3c88e1 100644 --- a/google/cloud/pubsub_v1/subscriber/scheduler.py +++ b/google/cloud/pubsub_v1/subscriber/scheduler.py @@ -162,7 +162,7 @@ def shutdown( work_item = self._executor._work_queue.get(block=False) if work_item is None: # Exceutor in shutdown mode. continue - dropped_messages.append(work_item.args[0]) + dropped_messages.append(work_item.args[0]) # type: ignore[index] except queue.Empty: pass diff --git a/noxfile.py b/noxfile.py index ae87830ec..61e73e0d4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -32,7 +32,7 @@ ISORT_VERSION = "isort==5.11.0" LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] -MYPY_VERSION = "mypy==0.910" +MYPY_VERSION = "mypy==1.10.0" DEFAULT_PYTHON_VERSION = "3.8" diff --git a/owlbot.py b/owlbot.py index d80434efd..3551413ee 100644 --- a/owlbot.py +++ b/owlbot.py @@ -348,7 +348,7 @@ s.replace( "noxfile.py", r"LINT_PATHS = \[.*?\]", - '\g<0>\n\nMYPY_VERSION = "mypy==0.910"', + '\g<0>\n\nMYPY_VERSION = "mypy==1.10.0"', ) s.replace( "noxfile.py", r'"blacken",', '\g<0>\n "mypy",',