Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit b221c8e

Browse files
authored
chore: librarian update image pull request: 20260326T182616Z (#1786)
feat: update image to us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:234b9d1f2ddb057ed7ac6a38db0bf8163d839c65c6cf88ade52530cddebce59e
1 parent bbdb510 commit b221c8e

21 files changed

+195
-54
lines changed

.librarian/state.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:8e2c32496077054105bd06c54a59d6a6694287bc053588e24debe6da6920ad91
1+
image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:234b9d1f2ddb057ed7ac6a38db0bf8163d839c65c6cf88ade52530cddebce59e
22
libraries:
33
- id: google-cloud-storage
44
version: 3.10.1

google/cloud/_storage_v2/__init__.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@
1515
#
1616
from google.cloud._storage_v2 import gapic_version as package_version
1717

18+
import google.api_core as api_core
19+
import sys
20+
1821
__version__ = package_version.__version__
1922

23+
if sys.version_info >= (3, 8): # pragma: NO COVER
24+
from importlib import metadata
25+
else: # pragma: NO COVER
26+
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
27+
# this code path once we drop support for Python 3.7
28+
import importlib_metadata as metadata
29+
2030

2131
from .services.storage import StorageClient
2232
from .services.storage import StorageAsyncClient
@@ -78,6 +88,100 @@
7888
from .types.storage import WriteObjectResponse
7989
from .types.storage import WriteObjectSpec
8090

91+
if hasattr(api_core, "check_python_version") and hasattr(
92+
api_core, "check_dependency_versions"
93+
): # pragma: NO COVER
94+
api_core.check_python_version("google.cloud._storage_v2") # type: ignore
95+
api_core.check_dependency_versions("google.cloud._storage_v2") # type: ignore
96+
else: # pragma: NO COVER
97+
# An older version of api_core is installed which does not define the
98+
# functions above. We do equivalent checks manually.
99+
try:
100+
import warnings
101+
import sys
102+
103+
_py_version_str = sys.version.split()[0]
104+
_package_label = "google.cloud._storage_v2"
105+
if sys.version_info < (3, 9):
106+
warnings.warn(
107+
"You are using a non-supported Python version "
108+
+ f"({_py_version_str}). Google will not post any further "
109+
+ f"updates to {_package_label} supporting this Python version. "
110+
+ "Please upgrade to the latest Python version, or at "
111+
+ f"least to Python 3.9, and then update {_package_label}.",
112+
FutureWarning,
113+
)
114+
if sys.version_info[:2] == (3, 9):
115+
warnings.warn(
116+
f"You are using a Python version ({_py_version_str}) "
117+
+ f"which Google will stop supporting in {_package_label} in "
118+
+ "January 2026. Please "
119+
+ "upgrade to the latest Python version, or at "
120+
+ "least to Python 3.10, before then, and "
121+
+ f"then update {_package_label}.",
122+
FutureWarning,
123+
)
124+
125+
def parse_version_to_tuple(version_string: str):
126+
"""Safely converts a semantic version string to a comparable tuple of integers.
127+
Example: "4.25.8" -> (4, 25, 8)
128+
Ignores non-numeric parts and handles common version formats.
129+
Args:
130+
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
131+
Returns:
132+
Tuple of integers for the parsed version string.
133+
"""
134+
parts = []
135+
for part in version_string.split("."):
136+
try:
137+
parts.append(int(part))
138+
except ValueError:
139+
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
140+
# This is a simplification compared to 'packaging.parse_version', but sufficient
141+
# for comparing strictly numeric semantic versions.
142+
break
143+
return tuple(parts)
144+
145+
def _get_version(dependency_name):
146+
try:
147+
version_string: str = metadata.version(dependency_name)
148+
parsed_version = parse_version_to_tuple(version_string)
149+
return (parsed_version, version_string)
150+
except Exception:
151+
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
152+
# or errors during parse_version_to_tuple
153+
return (None, "--")
154+
155+
_dependency_package = "google.protobuf"
156+
_next_supported_version = "4.25.8"
157+
_next_supported_version_tuple = (4, 25, 8)
158+
_recommendation = " (we recommend 6.x)"
159+
(_version_used, _version_used_string) = _get_version(_dependency_package)
160+
if _version_used and _version_used < _next_supported_version_tuple:
161+
warnings.warn(
162+
f"Package {_package_label} depends on "
163+
+ f"{_dependency_package}, currently installed at version "
164+
+ f"{_version_used_string}. Future updates to "
165+
+ f"{_package_label} will require {_dependency_package} at "
166+
+ f"version {_next_supported_version} or higher{_recommendation}."
167+
+ " Please ensure "
168+
+ "that either (a) your Python environment doesn't pin the "
169+
+ f"version of {_dependency_package}, so that updates to "
170+
+ f"{_package_label} can require the higher version, or "
171+
+ "(b) you manually update your Python environment to use at "
172+
+ f"least version {_next_supported_version} of "
173+
+ f"{_dependency_package}.",
174+
FutureWarning,
175+
)
176+
except Exception:
177+
warnings.warn(
178+
"Could not determine the version of Python "
179+
+ "currently being used. To continue receiving "
180+
+ "updates for {_package_label}, ensure you are "
181+
+ "using a supported version of Python; see "
182+
+ "https://devguide.python.org/versions/"
183+
)
184+
81185
__all__ = (
82186
"StorageAsyncClient",
83187
"AppendObjectSpec",

google/cloud/_storage_v2/services/storage/async_client.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@
5050

5151
from google.cloud._storage_v2.services.storage import pagers
5252
from google.cloud._storage_v2.types import storage
53-
from google.iam.v1 import iam_policy_pb2 # type: ignore
54-
from google.iam.v1 import policy_pb2 # type: ignore
5553
from google.longrunning import operations_pb2 # type: ignore
56-
from google.protobuf import field_mask_pb2 # type: ignore
57-
from google.protobuf import timestamp_pb2 # type: ignore
54+
import google.iam.v1.iam_policy_pb2 as iam_policy_pb2 # type: ignore
55+
import google.iam.v1.policy_pb2 as policy_pb2 # type: ignore
56+
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
57+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
5858
from .transports.base import StorageTransport, DEFAULT_CLIENT_INFO
5959
from .transports.grpc_asyncio import StorageGrpcAsyncIOTransport
6060
from .client import StorageClient
@@ -148,7 +148,8 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
148148
Returns:
149149
StorageAsyncClient: The constructed client.
150150
"""
151-
return StorageClient.from_service_account_info.__func__(StorageAsyncClient, info, *args, **kwargs) # type: ignore
151+
sa_info_func = StorageClient.from_service_account_info.__func__ # type: ignore
152+
return sa_info_func(StorageAsyncClient, info, *args, **kwargs)
152153

153154
@classmethod
154155
def from_service_account_file(cls, filename: str, *args, **kwargs):
@@ -164,7 +165,8 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
164165
Returns:
165166
StorageAsyncClient: The constructed client.
166167
"""
167-
return StorageClient.from_service_account_file.__func__(StorageAsyncClient, filename, *args, **kwargs) # type: ignore
168+
sa_file_func = StorageClient.from_service_account_file.__func__ # type: ignore
169+
return sa_file_func(StorageAsyncClient, filename, *args, **kwargs)
168170

169171
from_service_account_json = from_service_account_file
170172

@@ -214,7 +216,7 @@ def transport(self) -> StorageTransport:
214216
return self._client.transport
215217

216218
@property
217-
def api_endpoint(self):
219+
def api_endpoint(self) -> str:
218220
"""Return the API endpoint used by the client instance.
219221
220222
Returns:
@@ -1038,7 +1040,7 @@ async def get_iam_policy(
10381040
# client as shown in:
10391041
# https://googleapis.dev/python/google-api-core/latest/client_options.html
10401042
from google.cloud import storage_v2
1041-
from google.iam.v1 import iam_policy_pb2 # type: ignore
1043+
import google.iam.v1.iam_policy_pb2 as iam_policy_pb2 # type: ignore
10421044
10431045
async def sample_get_iam_policy():
10441046
# Create a client
@@ -1193,7 +1195,7 @@ async def set_iam_policy(
11931195
# client as shown in:
11941196
# https://googleapis.dev/python/google-api-core/latest/client_options.html
11951197
from google.cloud import storage_v2
1196-
from google.iam.v1 import iam_policy_pb2 # type: ignore
1198+
import google.iam.v1.iam_policy_pb2 as iam_policy_pb2 # type: ignore
11971199
11981200
async def sample_set_iam_policy():
11991201
# Create a client
@@ -1352,7 +1354,7 @@ async def test_iam_permissions(
13521354
# client as shown in:
13531355
# https://googleapis.dev/python/google-api-core/latest/client_options.html
13541356
from google.cloud import storage_v2
1355-
from google.iam.v1 import iam_policy_pb2 # type: ignore
1357+
import google.iam.v1.iam_policy_pb2 as iam_policy_pb2 # type: ignore
13561358
13571359
async def sample_test_iam_permissions():
13581360
# Create a client

google/cloud/_storage_v2/services/storage/transports/README.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
transport inheritance structure
33
_______________________________
44

5-
`StorageTransport` is the ABC for all transports.
6-
- public child `StorageGrpcTransport` for sync gRPC transport (defined in `grpc.py`).
7-
- public child `StorageGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`).
8-
- private child `_BaseStorageRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`).
9-
- public child `StorageRestTransport` for sync REST transport with inner classes `METHOD` derived from the parent's corresponding `_BaseMETHOD` classes (defined in `rest.py`).
5+
``StorageTransport`` is the ABC for all transports.
6+
7+
- public child ``StorageGrpcTransport`` for sync gRPC transport (defined in ``grpc.py``).
8+
- public child ``StorageGrpcAsyncIOTransport`` for async gRPC transport (defined in ``grpc_asyncio.py``).
9+
- private child ``_BaseStorageRestTransport`` for base REST transport with inner classes ``_BaseMETHOD`` (defined in ``rest_base.py``).
10+
- public child ``StorageRestTransport`` for sync REST transport with inner classes ``METHOD`` derived from the parent's corresponding ``_BaseMETHOD`` classes (defined in ``rest.py``).

google/cloud/_storage_v2/services/storage/transports/base.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
import google.protobuf
2929

3030
from google.cloud._storage_v2.types import storage
31-
from google.iam.v1 import iam_policy_pb2 # type: ignore
32-
from google.iam.v1 import policy_pb2 # type: ignore
3331
from google.longrunning import operations_pb2 # type: ignore
34-
from google.protobuf import empty_pb2 # type: ignore
32+
import google.iam.v1.iam_policy_pb2 as iam_policy_pb2 # type: ignore
33+
import google.iam.v1.policy_pb2 as policy_pb2 # type: ignore
34+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
3535

3636
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
3737
gapic_version=package_version.__version__
@@ -91,10 +91,12 @@ def __init__(
9191
your own client library.
9292
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
9393
be used for service account credentials.
94+
api_audience (Optional[str]): The intended audience for the API calls
95+
to the service that will be set when using certain 3rd party
96+
authentication flows. Audience is typically a resource identifier.
97+
If not set, the host value will be used as a default.
9498
"""
9599

96-
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
97-
98100
# Save the scopes.
99101
self._scopes = scopes
100102
if not hasattr(self, "_ignore_credentials"):
@@ -109,11 +111,16 @@ def __init__(
109111

110112
if credentials_file is not None:
111113
credentials, _ = google.auth.load_credentials_from_file(
112-
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
114+
credentials_file,
115+
scopes=scopes,
116+
quota_project_id=quota_project_id,
117+
default_scopes=self.AUTH_SCOPES,
113118
)
114119
elif credentials is None and not self._ignore_credentials:
115120
credentials, _ = google.auth.default(
116-
**scopes_kwargs, quota_project_id=quota_project_id
121+
scopes=scopes,
122+
quota_project_id=quota_project_id,
123+
default_scopes=self.AUTH_SCOPES,
117124
)
118125
# Don't apply audience if the credentials file passed from user.
119126
if hasattr(credentials, "with_gdch_audience"):
@@ -137,6 +144,8 @@ def __init__(
137144
host += ":443"
138145
self._host = host
139146

147+
self._wrapped_methods: Dict[Callable, Callable] = {}
148+
140149
@property
141150
def host(self):
142151
return self._host

google/cloud/_storage_v2/services/storage/transports/grpc.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
import proto # type: ignore
3232

3333
from google.cloud._storage_v2.types import storage
34-
from google.iam.v1 import iam_policy_pb2 # type: ignore
35-
from google.iam.v1 import policy_pb2 # type: ignore
3634
from google.longrunning import operations_pb2 # type: ignore
37-
from google.protobuf import empty_pb2 # type: ignore
35+
import google.iam.v1.iam_policy_pb2 as iam_policy_pb2 # type: ignore
36+
import google.iam.v1.policy_pb2 as policy_pb2 # type: ignore
37+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
3838
from .base import StorageTransport, DEFAULT_CLIENT_INFO
3939

4040
try:
@@ -59,7 +59,7 @@ def intercept_unary_unary(self, continuation, client_call_details, request):
5959
elif isinstance(request, google.protobuf.message.Message):
6060
request_payload = MessageToJson(request)
6161
else:
62-
request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
62+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
6363

6464
request_metadata = {
6565
key: value.decode("utf-8") if isinstance(value, bytes) else value
@@ -94,7 +94,7 @@ def intercept_unary_unary(self, continuation, client_call_details, request):
9494
elif isinstance(result, google.protobuf.message.Message):
9595
response_payload = MessageToJson(result)
9696
else:
97-
response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
97+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
9898
grpc_response = {
9999
"payload": response_payload,
100100
"metadata": metadata,
@@ -221,6 +221,10 @@ def __init__(
221221
your own client library.
222222
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
223223
be used for service account credentials.
224+
api_audience (Optional[str]): The intended audience for the API calls
225+
to the service that will be set when using certain 3rd party
226+
authentication flows. Audience is typically a resource identifier.
227+
If not set, the host value will be used as a default.
224228
225229
Raises:
226230
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport

google/cloud/_storage_v2/services/storage/transports/grpc_asyncio.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
from grpc.experimental import aio # type: ignore
3535

3636
from google.cloud._storage_v2.types import storage
37-
from google.iam.v1 import iam_policy_pb2 # type: ignore
38-
from google.iam.v1 import policy_pb2 # type: ignore
3937
from google.longrunning import operations_pb2 # type: ignore
40-
from google.protobuf import empty_pb2 # type: ignore
38+
import google.iam.v1.iam_policy_pb2 as iam_policy_pb2 # type: ignore
39+
import google.iam.v1.policy_pb2 as policy_pb2 # type: ignore
40+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
4141
from .base import StorageTransport, DEFAULT_CLIENT_INFO
4242
from .grpc import StorageGrpcTransport
4343

@@ -65,7 +65,7 @@ async def intercept_unary_unary(self, continuation, client_call_details, request
6565
elif isinstance(request, google.protobuf.message.Message):
6666
request_payload = MessageToJson(request)
6767
else:
68-
request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
68+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
6969

7070
request_metadata = {
7171
key: value.decode("utf-8") if isinstance(value, bytes) else value
@@ -100,7 +100,7 @@ async def intercept_unary_unary(self, continuation, client_call_details, request
100100
elif isinstance(result, google.protobuf.message.Message):
101101
response_payload = MessageToJson(result)
102102
else:
103-
response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
103+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
104104
grpc_response = {
105105
"payload": response_payload,
106106
"metadata": metadata,
@@ -272,6 +272,10 @@ def __init__(
272272
your own client library.
273273
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
274274
be used for service account credentials.
275+
api_audience (Optional[str]): The intended audience for the API calls
276+
to the service that will be set when using certain 3rd party
277+
authentication flows. Audience is typically a resource identifier.
278+
If not set, the host value will be used as a default.
275279
276280
Raises:
277281
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport

google/cloud/_storage_v2/types/storage.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
import proto # type: ignore
2121

22-
from google.protobuf import duration_pb2 # type: ignore
23-
from google.protobuf import field_mask_pb2 # type: ignore
24-
from google.protobuf import timestamp_pb2 # type: ignore
25-
from google.rpc import status_pb2 # type: ignore
26-
from google.type import date_pb2 # type: ignore
22+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
23+
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
24+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
25+
import google.rpc.status_pb2 as status_pb2 # type: ignore
26+
import google.type.date_pb2 as date_pb2 # type: ignore
2727

2828

2929
__protobuf__ = proto.module(

mypy.ini

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
[mypy]
2-
python_version = 3.7
2+
python_version = 3.14
33
namespace_packages = True
4+
ignore_missing_imports = False
5+
6+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563):
7+
# Dependencies that historically lacks py.typed markers
8+
[mypy-google.iam.*]
9+
ignore_missing_imports = True
10+
11+
# Helps mypy navigate the 'google' namespace more reliably in 3.10+
12+
explicit_package_bases = True
13+
14+
# Performance: reuse results from previous runs to speed up 'nox'
15+
incremental = True

0 commit comments

Comments
 (0)