From 43ba9cda070e834b1991198e2de4743ce7a0e436 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 26 Feb 2026 21:26:29 +0000 Subject: [PATCH] feat: update image to us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:160860d189ff1c2f7515638478823712fa5b243e27ccc33a2728669fa1e2ed0c --- .librarian/state.yaml | 2 +- .repo-metadata.json | 2 +- .../services/publisher/async_client.py | 14 ++++++++++---- google/pubsub_v1/services/publisher/client.py | 4 ++-- .../services/publisher/transports/base.py | 13 ++++++++----- .../services/publisher/transports/grpc.py | 2 +- .../publisher/transports/grpc_asyncio.py | 2 +- .../services/publisher/transports/rest.py | 4 ++-- .../services/publisher/transports/rest_base.py | 2 +- .../services/schema_service/async_client.py | 12 +++++++++--- .../pubsub_v1/services/schema_service/client.py | 2 +- .../services/schema_service/transports/base.py | 13 ++++++++----- .../services/schema_service/transports/grpc.py | 2 +- .../schema_service/transports/grpc_asyncio.py | 2 +- .../services/schema_service/transports/rest.py | 4 ++-- .../schema_service/transports/rest_base.py | 2 +- .../services/subscriber/async_client.py | 16 +++++++++++----- google/pubsub_v1/services/subscriber/client.py | 6 +++--- .../services/subscriber/transports/base.py | 13 ++++++++----- .../services/subscriber/transports/grpc.py | 2 +- .../subscriber/transports/grpc_asyncio.py | 2 +- .../services/subscriber/transports/rest.py | 12 ++++++------ .../services/subscriber/transports/rest_base.py | 2 +- google/pubsub_v1/types/pubsub.py | 8 ++++---- google/pubsub_v1/types/schema.py | 2 +- mypy.ini | 12 ++++++++++++ testing/constraints-3.10.txt | 2 ++ testing/constraints-3.11.txt | 2 ++ testing/constraints-3.12.txt | 2 ++ testing/constraints-3.7.txt | 15 +++++++++++++++ testing/constraints-3.8.txt | 11 +++++++++++ testing/constraints-3.9.txt | 2 ++ tests/unit/gapic/pubsub_v1/test_publisher.py | 17 +++++++++++------ .../unit/gapic/pubsub_v1/test_schema_service.py | 10 ++++++++-- tests/unit/gapic/pubsub_v1/test_subscriber.py | 16 +++++++++++----- 35 files changed, 162 insertions(+), 72 deletions(-) create mode 100644 testing/constraints-3.7.txt create mode 100644 testing/constraints-3.8.txt diff --git a/.librarian/state.yaml b/.librarian/state.yaml index 2d5b23ac6..f76eba985 100644 --- a/.librarian/state.yaml +++ b/.librarian/state.yaml @@ -1,4 +1,4 @@ -image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209 +image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:160860d189ff1c2f7515638478823712fa5b243e27ccc33a2728669fa1e2ed0c libraries: - id: google-cloud-pubsub version: 2.35.0 diff --git a/.repo-metadata.json b/.repo-metadata.json index f65318dba..8d12e4cc0 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -11,7 +11,7 @@ "api_id": "pubsub.googleapis.com", "requires_billing": true, "default_version": "v1", - "codeowner_team": "@googleapis/cloud-sdk-python-team @googleapis/pubsub-team", + "codeowner_team": "@googleapis/api-pubsub", "api_shortname": "pubsub", "library_type": "GAPIC_COMBO", "api_description": "is designed to provide reliable, many-to-many, asynchronous messaging between applications. Publisher applications can send messages to a topic and other applications can subscribe to that topic to receive the messages. By decoupling senders and receivers, Google Cloud Pub/Sub allows developers to communicate between independently written applications." diff --git a/google/pubsub_v1/services/publisher/async_client.py b/google/pubsub_v1/services/publisher/async_client.py index 9f52347d4..caa329934 100644 --- a/google/pubsub_v1/services/publisher/async_client.py +++ b/google/pubsub_v1/services/publisher/async_client.py @@ -47,11 +47,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore from google.pubsub_v1.services.publisher import pagers from google.pubsub_v1.types import pubsub from google.pubsub_v1.types import TimeoutType +import google.protobuf.duration_pb2 as duration_pb2 # type: ignore +import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore from .transports.base import PublisherTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import PublisherGrpcAsyncIOTransport from .client import PublisherClient @@ -122,7 +122,10 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): Returns: PublisherAsyncClient: The constructed client. """ - return PublisherClient.from_service_account_info.__func__(PublisherAsyncClient, info, *args, **kwargs) # type: ignore + sa_info_func = ( + PublisherClient.from_service_account_info.__func__ # type: ignore + ) + return sa_info_func(PublisherAsyncClient, info, *args, **kwargs) @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): @@ -138,7 +141,10 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): Returns: PublisherAsyncClient: The constructed client. """ - return PublisherClient.from_service_account_file.__func__(PublisherAsyncClient, filename, *args, **kwargs) # type: ignore + sa_file_func = ( + PublisherClient.from_service_account_file.__func__ # type: ignore + ) + return sa_file_func(PublisherAsyncClient, filename, *args, **kwargs) from_service_account_json = from_service_account_file diff --git a/google/pubsub_v1/services/publisher/client.py b/google/pubsub_v1/services/publisher/client.py index 7467b7540..9c9d85caa 100644 --- a/google/pubsub_v1/services/publisher/client.py +++ b/google/pubsub_v1/services/publisher/client.py @@ -65,11 +65,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore from google.pubsub_v1.services.publisher import pagers from google.pubsub_v1.types import pubsub from google.pubsub_v1.types import TimeoutType +import google.protobuf.duration_pb2 as duration_pb2 # type: ignore +import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore import grpc from .transports.base import PublisherTransport, DEFAULT_CLIENT_INFO diff --git a/google/pubsub_v1/services/publisher/transports/base.py b/google/pubsub_v1/services/publisher/transports/base.py index b9d6a6279..cc0d6223b 100644 --- a/google/pubsub_v1/services/publisher/transports/base.py +++ b/google/pubsub_v1/services/publisher/transports/base.py @@ -29,8 +29,8 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import pubsub +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( client_library_version=package_version.__version__ @@ -89,8 +89,6 @@ def __init__( be used for service account credentials. """ - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} - # Save the scopes. self._scopes = scopes if not hasattr(self, "_ignore_credentials"): @@ -105,11 +103,16 @@ def __init__( if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( - credentials_file, **scopes_kwargs, quota_project_id=quota_project_id + credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + default_scopes=self.AUTH_SCOPES, ) elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( - **scopes_kwargs, quota_project_id=quota_project_id + scopes=scopes, + quota_project_id=quota_project_id, + default_scopes=self.AUTH_SCOPES, ) # Don't apply audience if the credentials file passed from user. if hasattr(credentials, "with_gdch_audience"): diff --git a/google/pubsub_v1/services/publisher/transports/grpc.py b/google/pubsub_v1/services/publisher/transports/grpc.py index e192152d8..ce11e2f61 100644 --- a/google/pubsub_v1/services/publisher/transports/grpc.py +++ b/google/pubsub_v1/services/publisher/transports/grpc.py @@ -32,8 +32,8 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import pubsub +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore from .base import PublisherTransport, DEFAULT_CLIENT_INFO try: diff --git a/google/pubsub_v1/services/publisher/transports/grpc_asyncio.py b/google/pubsub_v1/services/publisher/transports/grpc_asyncio.py index 14b9fdd06..1897656d9 100644 --- a/google/pubsub_v1/services/publisher/transports/grpc_asyncio.py +++ b/google/pubsub_v1/services/publisher/transports/grpc_asyncio.py @@ -35,8 +35,8 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import pubsub +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore from .base import PublisherTransport, DEFAULT_CLIENT_INFO from .grpc import PublisherGrpcTransport diff --git a/google/pubsub_v1/services/publisher/transports/rest.py b/google/pubsub_v1/services/publisher/transports/rest.py index aeb07184c..e315108e0 100644 --- a/google/pubsub_v1/services/publisher/transports/rest.py +++ b/google/pubsub_v1/services/publisher/transports/rest.py @@ -35,8 +35,8 @@ import warnings -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import pubsub +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore from .rest_base import _BasePublisherRestTransport @@ -918,7 +918,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = json_format.MessageToJson(request) + request_payload = type(request).to_json(request) except: request_payload = None http_request = { diff --git a/google/pubsub_v1/services/publisher/transports/rest_base.py b/google/pubsub_v1/services/publisher/transports/rest_base.py index 14308a300..58be96a85 100644 --- a/google/pubsub_v1/services/publisher/transports/rest_base.py +++ b/google/pubsub_v1/services/publisher/transports/rest_base.py @@ -26,8 +26,8 @@ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import pubsub +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore class _BasePublisherRestTransport(PublisherTransport): diff --git a/google/pubsub_v1/services/schema_service/async_client.py b/google/pubsub_v1/services/schema_service/async_client.py index b2d139fa0..9b59fe64f 100644 --- a/google/pubsub_v1/services/schema_service/async_client.py +++ b/google/pubsub_v1/services/schema_service/async_client.py @@ -47,10 +47,10 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore from google.pubsub_v1.services.schema_service import pagers from google.pubsub_v1.types import schema from google.pubsub_v1.types import schema as gp_schema +import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore from .transports.base import SchemaServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import SchemaServiceGrpcAsyncIOTransport from .client import SchemaServiceClient @@ -117,7 +117,10 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): Returns: SchemaServiceAsyncClient: The constructed client. """ - return SchemaServiceClient.from_service_account_info.__func__(SchemaServiceAsyncClient, info, *args, **kwargs) # type: ignore + sa_info_func = ( + SchemaServiceClient.from_service_account_info.__func__ # type: ignore + ) + return sa_info_func(SchemaServiceAsyncClient, info, *args, **kwargs) @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): @@ -133,7 +136,10 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): Returns: SchemaServiceAsyncClient: The constructed client. """ - return SchemaServiceClient.from_service_account_file.__func__(SchemaServiceAsyncClient, filename, *args, **kwargs) # type: ignore + sa_file_func = ( + SchemaServiceClient.from_service_account_file.__func__ # type: ignore + ) + return sa_file_func(SchemaServiceAsyncClient, filename, *args, **kwargs) from_service_account_json = from_service_account_file diff --git a/google/pubsub_v1/services/schema_service/client.py b/google/pubsub_v1/services/schema_service/client.py index 300f23998..e3bcf3ab5 100644 --- a/google/pubsub_v1/services/schema_service/client.py +++ b/google/pubsub_v1/services/schema_service/client.py @@ -64,10 +64,10 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore from google.pubsub_v1.services.schema_service import pagers from google.pubsub_v1.types import schema from google.pubsub_v1.types import schema as gp_schema +import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore import grpc from .transports.base import SchemaServiceTransport, DEFAULT_CLIENT_INFO diff --git a/google/pubsub_v1/services/schema_service/transports/base.py b/google/pubsub_v1/services/schema_service/transports/base.py index bfe254e0a..6131b4b8d 100644 --- a/google/pubsub_v1/services/schema_service/transports/base.py +++ b/google/pubsub_v1/services/schema_service/transports/base.py @@ -29,9 +29,9 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import schema from google.pubsub_v1.types import schema as gp_schema +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( client_library_version=package_version.__version__ @@ -90,8 +90,6 @@ def __init__( be used for service account credentials. """ - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} - # Save the scopes. self._scopes = scopes if not hasattr(self, "_ignore_credentials"): @@ -106,11 +104,16 @@ def __init__( if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( - credentials_file, **scopes_kwargs, quota_project_id=quota_project_id + credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + default_scopes=self.AUTH_SCOPES, ) elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( - **scopes_kwargs, quota_project_id=quota_project_id + scopes=scopes, + quota_project_id=quota_project_id, + default_scopes=self.AUTH_SCOPES, ) # Don't apply audience if the credentials file passed from user. if hasattr(credentials, "with_gdch_audience"): diff --git a/google/pubsub_v1/services/schema_service/transports/grpc.py b/google/pubsub_v1/services/schema_service/transports/grpc.py index 5bcfd8b9b..0f26d425a 100644 --- a/google/pubsub_v1/services/schema_service/transports/grpc.py +++ b/google/pubsub_v1/services/schema_service/transports/grpc.py @@ -32,9 +32,9 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import schema from google.pubsub_v1.types import schema as gp_schema +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore from .base import SchemaServiceTransport, DEFAULT_CLIENT_INFO try: diff --git a/google/pubsub_v1/services/schema_service/transports/grpc_asyncio.py b/google/pubsub_v1/services/schema_service/transports/grpc_asyncio.py index ac2980ded..93731eae9 100644 --- a/google/pubsub_v1/services/schema_service/transports/grpc_asyncio.py +++ b/google/pubsub_v1/services/schema_service/transports/grpc_asyncio.py @@ -35,9 +35,9 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import schema from google.pubsub_v1.types import schema as gp_schema +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore from .base import SchemaServiceTransport, DEFAULT_CLIENT_INFO from .grpc import SchemaServiceGrpcTransport diff --git a/google/pubsub_v1/services/schema_service/transports/rest.py b/google/pubsub_v1/services/schema_service/transports/rest.py index a0d42c2dd..fb94e9227 100644 --- a/google/pubsub_v1/services/schema_service/transports/rest.py +++ b/google/pubsub_v1/services/schema_service/transports/rest.py @@ -35,9 +35,9 @@ import warnings -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import schema from google.pubsub_v1.types import schema as gp_schema +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore from .rest_base import _BaseSchemaServiceRestTransport @@ -1116,7 +1116,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = json_format.MessageToJson(request) + request_payload = type(request).to_json(request) except: request_payload = None http_request = { diff --git a/google/pubsub_v1/services/schema_service/transports/rest_base.py b/google/pubsub_v1/services/schema_service/transports/rest_base.py index 0ce5285bd..ae952cc46 100644 --- a/google/pubsub_v1/services/schema_service/transports/rest_base.py +++ b/google/pubsub_v1/services/schema_service/transports/rest_base.py @@ -26,9 +26,9 @@ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import schema from google.pubsub_v1.types import schema as gp_schema +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore class _BaseSchemaServiceRestTransport(SchemaServiceTransport): diff --git a/google/pubsub_v1/services/subscriber/async_client.py b/google/pubsub_v1/services/subscriber/async_client.py index a7f1cc3f5..7b1882ecf 100644 --- a/google/pubsub_v1/services/subscriber/async_client.py +++ b/google/pubsub_v1/services/subscriber/async_client.py @@ -51,11 +51,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore from google.pubsub_v1.services.subscriber import pagers from google.pubsub_v1.types import pubsub +import google.protobuf.duration_pb2 as duration_pb2 # type: ignore +import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore +import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore from .transports.base import SubscriberTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import SubscriberGrpcAsyncIOTransport from .client import SubscriberClient @@ -126,7 +126,10 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): Returns: SubscriberAsyncClient: The constructed client. """ - return SubscriberClient.from_service_account_info.__func__(SubscriberAsyncClient, info, *args, **kwargs) # type: ignore + sa_info_func = ( + SubscriberClient.from_service_account_info.__func__ # type: ignore + ) + return sa_info_func(SubscriberAsyncClient, info, *args, **kwargs) @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): @@ -142,7 +145,10 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): Returns: SubscriberAsyncClient: The constructed client. """ - return SubscriberClient.from_service_account_file.__func__(SubscriberAsyncClient, filename, *args, **kwargs) # type: ignore + sa_file_func = ( + SubscriberClient.from_service_account_file.__func__ # type: ignore + ) + return sa_file_func(SubscriberAsyncClient, filename, *args, **kwargs) from_service_account_json = from_service_account_file diff --git a/google/pubsub_v1/services/subscriber/client.py b/google/pubsub_v1/services/subscriber/client.py index 23e7ff6d0..0c26ee926 100644 --- a/google/pubsub_v1/services/subscriber/client.py +++ b/google/pubsub_v1/services/subscriber/client.py @@ -67,11 +67,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore from google.pubsub_v1.services.subscriber import pagers from google.pubsub_v1.types import pubsub +import google.protobuf.duration_pb2 as duration_pb2 # type: ignore +import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore +import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore import grpc from .transports.base import SubscriberTransport, DEFAULT_CLIENT_INFO diff --git a/google/pubsub_v1/services/subscriber/transports/base.py b/google/pubsub_v1/services/subscriber/transports/base.py index a25ff562f..bd27398ba 100644 --- a/google/pubsub_v1/services/subscriber/transports/base.py +++ b/google/pubsub_v1/services/subscriber/transports/base.py @@ -29,8 +29,8 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import pubsub +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( client_library_version=package_version.__version__ @@ -89,8 +89,6 @@ def __init__( be used for service account credentials. """ - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} - # Save the scopes. self._scopes = scopes if not hasattr(self, "_ignore_credentials"): @@ -105,11 +103,16 @@ def __init__( if credentials_file is not None: credentials, _ = google.auth.load_credentials_from_file( - credentials_file, **scopes_kwargs, quota_project_id=quota_project_id + credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + default_scopes=self.AUTH_SCOPES, ) elif credentials is None and not self._ignore_credentials: credentials, _ = google.auth.default( - **scopes_kwargs, quota_project_id=quota_project_id + scopes=scopes, + quota_project_id=quota_project_id, + default_scopes=self.AUTH_SCOPES, ) # Don't apply audience if the credentials file passed from user. if hasattr(credentials, "with_gdch_audience"): diff --git a/google/pubsub_v1/services/subscriber/transports/grpc.py b/google/pubsub_v1/services/subscriber/transports/grpc.py index 705163791..acb84e94c 100644 --- a/google/pubsub_v1/services/subscriber/transports/grpc.py +++ b/google/pubsub_v1/services/subscriber/transports/grpc.py @@ -32,8 +32,8 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import pubsub +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore from .base import SubscriberTransport, DEFAULT_CLIENT_INFO try: diff --git a/google/pubsub_v1/services/subscriber/transports/grpc_asyncio.py b/google/pubsub_v1/services/subscriber/transports/grpc_asyncio.py index ad53fe76c..7d45595e0 100644 --- a/google/pubsub_v1/services/subscriber/transports/grpc_asyncio.py +++ b/google/pubsub_v1/services/subscriber/transports/grpc_asyncio.py @@ -35,8 +35,8 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import pubsub +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore from .base import SubscriberTransport, DEFAULT_CLIENT_INFO from .grpc import SubscriberGrpcTransport diff --git a/google/pubsub_v1/services/subscriber/transports/rest.py b/google/pubsub_v1/services/subscriber/transports/rest.py index 50a247cef..c9784503d 100644 --- a/google/pubsub_v1/services/subscriber/transports/rest.py +++ b/google/pubsub_v1/services/subscriber/transports/rest.py @@ -35,8 +35,8 @@ import warnings -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import pubsub +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore from .rest_base import _BaseSubscriberRestTransport @@ -951,7 +951,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = json_format.MessageToJson(request) + request_payload = type(request).to_json(request) except: request_payload = None http_request = { @@ -1379,7 +1379,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = json_format.MessageToJson(request) + request_payload = type(request).to_json(request) except: request_payload = None http_request = { @@ -1488,7 +1488,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = json_format.MessageToJson(request) + request_payload = type(request).to_json(request) except: request_payload = None http_request = { @@ -2203,7 +2203,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = json_format.MessageToJson(request) + request_payload = type(request).to_json(request) except: request_payload = None http_request = { @@ -2318,7 +2318,7 @@ def __call__( ) method = transcoded_request["method"] try: - request_payload = json_format.MessageToJson(request) + request_payload = type(request).to_json(request) except: request_payload = None http_request = { diff --git a/google/pubsub_v1/services/subscriber/transports/rest_base.py b/google/pubsub_v1/services/subscriber/transports/rest_base.py index f4fb07656..6c557f85e 100644 --- a/google/pubsub_v1/services/subscriber/transports/rest_base.py +++ b/google/pubsub_v1/services/subscriber/transports/rest_base.py @@ -26,8 +26,8 @@ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -from google.protobuf import empty_pb2 # type: ignore from google.pubsub_v1.types import pubsub +import google.protobuf.empty_pb2 as empty_pb2 # type: ignore class _BaseSubscriberRestTransport(SubscriberTransport): diff --git a/google/pubsub_v1/types/pubsub.py b/google/pubsub_v1/types/pubsub.py index 1a5663c29..c76c7d7f1 100644 --- a/google/pubsub_v1/types/pubsub.py +++ b/google/pubsub_v1/types/pubsub.py @@ -19,11 +19,11 @@ import proto # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore from google.pubsub_v1.types import schema as gp_schema +import google.protobuf.duration_pb2 as duration_pb2 # type: ignore +import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore +import google.protobuf.struct_pb2 as struct_pb2 # type: ignore +import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore __protobuf__ = proto.module( diff --git a/google/pubsub_v1/types/schema.py b/google/pubsub_v1/types/schema.py index e1f376ed9..d3baa4bcd 100644 --- a/google/pubsub_v1/types/schema.py +++ b/google/pubsub_v1/types/schema.py @@ -19,7 +19,7 @@ import proto # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore +import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore __protobuf__ = proto.module( diff --git a/mypy.ini b/mypy.ini index a3cb5c292..e0e0da2e9 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,3 +1,15 @@ [mypy] python_version = 3.14 namespace_packages = True +ignore_missing_imports = False + +# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563): +# Dependencies that historically lacks py.typed markers +[mypy-google.iam.*] +ignore_missing_imports = True + +# Helps mypy navigate the 'google' namespace more reliably in 3.10+ +explicit_package_bases = True + +# Performance: reuse results from previous runs to speed up 'nox' +incremental = True diff --git a/testing/constraints-3.10.txt b/testing/constraints-3.10.txt index ef1c92fff..1cd0c5a2c 100644 --- a/testing/constraints-3.10.txt +++ b/testing/constraints-3.10.txt @@ -6,4 +6,6 @@ google-auth grpcio proto-plus protobuf +# cryptography is a direct dependency of google-auth +cryptography grpc-google-iam-v1 diff --git a/testing/constraints-3.11.txt b/testing/constraints-3.11.txt index ef1c92fff..1cd0c5a2c 100644 --- a/testing/constraints-3.11.txt +++ b/testing/constraints-3.11.txt @@ -6,4 +6,6 @@ google-auth grpcio proto-plus protobuf +# cryptography is a direct dependency of google-auth +cryptography grpc-google-iam-v1 diff --git a/testing/constraints-3.12.txt b/testing/constraints-3.12.txt index ef1c92fff..1cd0c5a2c 100644 --- a/testing/constraints-3.12.txt +++ b/testing/constraints-3.12.txt @@ -6,4 +6,6 @@ google-auth grpcio proto-plus protobuf +# cryptography is a direct dependency of google-auth +cryptography grpc-google-iam-v1 diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt new file mode 100644 index 000000000..9907cdc23 --- /dev/null +++ b/testing/constraints-3.7.txt @@ -0,0 +1,15 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List all library dependencies and extras in this file. +# Pin the version to the lower bound. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0", +# Then this file should have google-cloud-foo==1.14.0 +google-api-core==1.34.1 +google-auth==2.14.1 +# cryptography is a direct dependency of google-auth +cryptography==38.0.3 +# TODO(https://github.com/googleapis/gapic-generator-python/issues/2453) +# Add the minimum supported version of grpcio to constraints files +proto-plus==1.22.3 +protobuf==3.20.2 +grpc-google-iam-v1==0.14.0 diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt new file mode 100644 index 000000000..1cd0c5a2c --- /dev/null +++ b/testing/constraints-3.8.txt @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +google-auth +grpcio +proto-plus +protobuf +# cryptography is a direct dependency of google-auth +cryptography +grpc-google-iam-v1 diff --git a/testing/constraints-3.9.txt b/testing/constraints-3.9.txt index ef1c92fff..1cd0c5a2c 100644 --- a/testing/constraints-3.9.txt +++ b/testing/constraints-3.9.txt @@ -6,4 +6,6 @@ google-auth grpcio proto-plus protobuf +# cryptography is a direct dependency of google-auth +cryptography grpc-google-iam-v1 diff --git a/tests/unit/gapic/pubsub_v1/test_publisher.py b/tests/unit/gapic/pubsub_v1/test_publisher.py index 0edfbd382..d3f704c0b 100644 --- a/tests/unit/gapic/pubsub_v1/test_publisher.py +++ b/tests/unit/gapic/pubsub_v1/test_publisher.py @@ -15,8 +15,12 @@ # import os - -import mock +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock # pragma: NO COVER +except ImportError: # pragma: NO COVER + import mock import grpc from grpc.experimental import aio @@ -25,6 +29,7 @@ import json import math import pytest +from collections.abc import Sequence, Mapping from google.api_core import api_core_version from proto.marshal.rules.dates import DurationRule, TimestampRule from proto.marshal.rules import wrappers @@ -53,10 +58,6 @@ from google.iam.v1 import options_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore from google.pubsub_v1.services.publisher import PublisherAsyncClient from google.pubsub_v1.services.publisher import PublisherClient from google.pubsub_v1.services.publisher import pagers @@ -64,6 +65,10 @@ from google.pubsub_v1.types import pubsub from google.pubsub_v1.types import schema import google.auth +import google.protobuf.duration_pb2 as duration_pb2 # type: ignore +import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore +import google.protobuf.struct_pb2 as struct_pb2 # type: ignore +import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore CRED_INFO_JSON = { diff --git a/tests/unit/gapic/pubsub_v1/test_schema_service.py b/tests/unit/gapic/pubsub_v1/test_schema_service.py index 76dd7b1f8..35b0a8f31 100644 --- a/tests/unit/gapic/pubsub_v1/test_schema_service.py +++ b/tests/unit/gapic/pubsub_v1/test_schema_service.py @@ -15,7 +15,12 @@ # import os -import mock +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock # pragma: NO COVER +except ImportError: # pragma: NO COVER + import mock import grpc from grpc.experimental import aio @@ -24,6 +29,7 @@ import json import math import pytest +from collections.abc import Sequence, Mapping from google.api_core import api_core_version from proto.marshal.rules.dates import DurationRule, TimestampRule from proto.marshal.rules import wrappers @@ -52,7 +58,6 @@ from google.iam.v1 import options_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account -from google.protobuf import timestamp_pb2 # type: ignore from google.pubsub_v1.services.schema_service import SchemaServiceAsyncClient from google.pubsub_v1.services.schema_service import SchemaServiceClient from google.pubsub_v1.services.schema_service import pagers @@ -60,6 +65,7 @@ from google.pubsub_v1.types import schema from google.pubsub_v1.types import schema as gp_schema import google.auth +import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore CRED_INFO_JSON = { diff --git a/tests/unit/gapic/pubsub_v1/test_subscriber.py b/tests/unit/gapic/pubsub_v1/test_subscriber.py index 1aa2e55c9..0a3fd40e5 100644 --- a/tests/unit/gapic/pubsub_v1/test_subscriber.py +++ b/tests/unit/gapic/pubsub_v1/test_subscriber.py @@ -16,7 +16,12 @@ import os import warnings -import mock +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock # pragma: NO COVER +except ImportError: # pragma: NO COVER + import mock import grpc from grpc.experimental import aio @@ -25,6 +30,7 @@ import json import math import pytest +from collections.abc import Sequence, Mapping from google.api_core import api_core_version from proto.marshal.rules.dates import DurationRule, TimestampRule from proto.marshal.rules import wrappers @@ -53,16 +59,16 @@ from google.iam.v1 import options_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore from google.pubsub_v1.services.subscriber import SubscriberAsyncClient from google.pubsub_v1.services.subscriber import SubscriberClient from google.pubsub_v1.services.subscriber import pagers from google.pubsub_v1.services.subscriber import transports from google.pubsub_v1.types import pubsub import google.auth +import google.protobuf.duration_pb2 as duration_pb2 # type: ignore +import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore +import google.protobuf.struct_pb2 as struct_pb2 # type: ignore +import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore CRED_INFO_JSON = {