Changes for release V31.2.0. · googleads/google-ads-python@23a0bf4 · GitHub
Skip to content

Commit 23a0bf4

Browse files
committed
Changes for release V31.2.0.
1 parent e43bef8 commit 23a0bf4

1,814 files changed

Lines changed: 446113 additions & 8 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎ChangeLog‎

Lines changed: 5 additions & 0 deletions

‎google/ads/googleads/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import google.ads.googleads.errors
2020
import google.ads.googleads.util
2121

22-
VERSION = "31.1.0"
22+
VERSION = "31.2.0"
2323

2424
# Checks if the current runtime is Python 3.10.
2525
if sys.version_info.major == 3 and sys.version_info.minor <= 10:

‎google/ads/googleads/client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
_SERVICE_CLIENT_TEMPLATE = "{}Client"
4646
_ASYNC_SERVICE_CLIENT_TEMPLATE = "{}AsyncClient"
4747

48-
_VALID_API_VERSIONS = ["v24", "v23", "v22", "v21"]
48+
_VALID_API_VERSIONS = ["v25", "v24", "v23", "v22", "v21"]
4949
_MESSAGE_TYPES = ["common", "enums", "errors", "resources", "services"]
5050
_DEFAULT_VERSION = _VALID_API_VERSIONS[0]
5151

‎google/ads/googleads/interceptors/helpers.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"Feed": ["places_location_feed_data.email_address"],
4848
"LocalServicesLead": [
4949
"contact_details.phone_number",
50-
"contact_details.email",
50+
"contact_details.phone_number_extension",
51+
"contact_details.email", # TODO: remove this after v24 is sunset.
5152
"contact_details.consumer_name",
5253
],
5354
"LocalServicesLeadConversation": ["message_details.text"],
@@ -114,7 +115,7 @@ def _mask_message_fields(
114115
# AttributeError is raised when the field is not defined on the
115116
# message. In this case there's nothing to mask and the field
116117
# should be skipped.
117-
break
118+
pass
118119

119120
return copy
120121

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
from google.ads.googleads.v25 import gapic_version as package_version
17+
18+
import google.api_core as api_core
19+
import sys
20+
21+
__version__ = package_version.__version__
22+
23+
from importlib import metadata
24+
25+
# PEP 0810: Explicit Lazy Imports
26+
# Python 3.15+ natively intercepts and defers these imports.
27+
# Developers can disable this behavior and force eager imports.
28+
# For more information, see:
29+
# https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter
30+
# Older Python versions safely ignore this variable.
31+
__lazy_modules__ = {
32+
"google.ads.googleads.v25.actions",
33+
"google.ads.googleads.v25.common",
34+
"google.ads.googleads.v25.enums",
35+
"google.ads.googleads.v25.errors",
36+
"google.ads.googleads.v25.resources",
37+
"google.ads.googleads.v25.services",
38+
}
39+
40+
from . import actions
41+
from . import common
42+
from . import enums
43+
from . import errors
44+
from . import resources
45+
from . import services
46+
47+
48+
if hasattr(api_core, "check_python_version") and hasattr(
49+
api_core, "check_dependency_versions"
50+
): # pragma: NO COVER
51+
api_core.check_python_version("google.ads.googleads.v25") # type: ignore
52+
api_core.check_dependency_versions("google.ads.googleads.v25") # type: ignore
53+
else: # pragma: NO COVER
54+
# An older version of api_core is installed which does not define the
55+
# functions above. We do equivalent checks manually.
56+
try:
57+
import warnings
58+
59+
_py_version_str = sys.version.split()[0]
60+
_package_label = "google.ads.googleads.v25"
61+
if sys.version_info < (3, 10):
62+
warnings.warn(
63+
"You are using a non-supported Python version "
64+
+ f"({_py_version_str}). Google will not post any further "
65+
+ f"updates to {_package_label} supporting this Python version. "
66+
+ "Please upgrade to the latest Python version, or at "
67+
+ f"least to Python 3.10, and then update {_package_label}.",
68+
FutureWarning,
69+
)
70+
71+
def parse_version_to_tuple(version_string: str):
72+
"""Safely converts a semantic version string to a comparable tuple of integers.
73+
Example: "6.33.5" -> (6, 33, 5)
74+
Ignores non-numeric parts and handles common version formats.
75+
Args:
76+
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
77+
Returns:
78+
Tuple of integers for the parsed version string.
79+
"""
80+
parts = []
81+
for part in version_string.split("."):
82+
try:
83+
parts.append(int(part))
84+
except ValueError:
85+
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
86+
# This is a simplification compared to 'packaging.parse_version', but sufficient
87+
# for comparing strictly numeric semantic versions.
88+
break
89+
return tuple(parts)
90+
91+
def _get_version(dependency_name):
92+
try:
93+
version_string: str = metadata.version(dependency_name)
94+
parsed_version = parse_version_to_tuple(version_string)
95+
return (parsed_version, version_string)
96+
except Exception:
97+
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
98+
# or errors during parse_version_to_tuple
99+
return (None, "--")
100+
101+
_dependency_package = "google.protobuf"
102+
_next_supported_version = "6.33.5"
103+
_next_supported_version_tuple = (6, 33, 5)
104+
_recommendation = " (we recommend 7.x)"
105+
(_version_used, _version_used_string) = _get_version(
106+
_dependency_package
107+
)
108+
if _version_used and _version_used < _next_supported_version_tuple:
109+
warnings.warn(
110+
f"Package {_package_label} depends on "
111+
+ f"{_dependency_package}, currently installed at version "
112+
+ f"{_version_used_string}. Future updates to "
113+
+ f"{_package_label} will require {_dependency_package} at "
114+
+ f"version {_next_supported_version} or higher{_recommendation}."
115+
+ " Please ensure "
116+
+ "that either (a) your Python environment doesn't pin the "
117+
+ f"version of {_dependency_package}, so that updates to "
118+
+ f"{_package_label} can require the higher version, or "
119+
+ "(b) you manually update your Python environment to use at "
120+
+ f"least version {_next_supported_version} of "
121+
+ f"{_dependency_package}.",
122+
FutureWarning,
123+
)
124+
except Exception:
125+
warnings.warn(
126+
"Could not determine the version of Python "
127+
+ "currently being used. To continue receiving "
128+
+ "updates for {_package_label}, ensure you are "
129+
+ "using a supported version of Python; see "
130+
+ "https://devguide.python.org/versions/"
131+
)
132+
133+
__all__ = (
134+
"actions",
135+
"common",
136+
"enums",
137+
"errors",
138+
"resources",
139+
"services",
140+
)
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
from google.ads.googleads.v25 import gapic_version as package_version
17+
18+
import google.api_core as api_core
19+
import sys
20+
21+
__version__ = package_version.__version__
22+
23+
from importlib import metadata
24+
25+
# PEP 0810: Explicit Lazy Imports
26+
# Python 3.15+ natively intercepts and defers these imports.
27+
# Developers can disable this behavior and force eager imports.
28+
# For more information, see:
29+
# https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter
30+
# Older Python versions safely ignore this variable.
31+
__lazy_modules__ = {
32+
"google.ads.googleads.v25.types.book_campaigns",
33+
"google.ads.googleads.v25.types.generate_shareable_previews",
34+
"google.ads.googleads.v25.types.quote_campaigns",
35+
}
36+
37+
38+
from .types.book_campaigns import BookCampaignsOperation
39+
from .types.book_campaigns import BookCampaignsResult
40+
from .types.generate_shareable_previews import (
41+
GenerateShareablePreviewsOperation,
42+
)
43+
from .types.generate_shareable_previews import GenerateShareablePreviewsResult
44+
from .types.generate_shareable_previews import ShareablePreview
45+
from .types.generate_shareable_previews import ShareablePreviewResult
46+
from .types.generate_shareable_previews import UiPreviewResult
47+
from .types.generate_shareable_previews import YouTubeLivePreviewResult
48+
from .types.quote_campaigns import QuoteCampaignsOperation
49+
from .types.quote_campaigns import QuoteCampaignsResult
50+
51+
if hasattr(api_core, "check_python_version") and hasattr(
52+
api_core, "check_dependency_versions"
53+
): # pragma: NO COVER
54+
api_core.check_python_version("google.ads.googleads.v25") # type: ignore
55+
api_core.check_dependency_versions("google.ads.googleads.v25") # type: ignore
56+
else: # pragma: NO COVER
57+
# An older version of api_core is installed which does not define the
58+
# functions above. We do equivalent checks manually.
59+
try:
60+
import warnings
61+
62+
_py_version_str = sys.version.split()[0]
63+
_package_label = "google.ads.googleads.v25"
64+
if sys.version_info < (3, 10):
65+
warnings.warn(
66+
"You are using a non-supported Python version "
67+
+ f"({_py_version_str}). Google will not post any further "
68+
+ f"updates to {_package_label} supporting this Python version. "
69+
+ "Please upgrade to the latest Python version, or at "
70+
+ f"least to Python 3.10, and then update {_package_label}.",
71+
FutureWarning,
72+
)
73+
74+
def parse_version_to_tuple(version_string: str):
75+
"""Safely converts a semantic version string to a comparable tuple of integers.
76+
Example: "6.33.5" -> (6, 33, 5)
77+
Ignores non-numeric parts and handles common version formats.
78+
Args:
79+
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
80+
Returns:
81+
Tuple of integers for the parsed version string.
82+
"""
83+
parts = []
84+
for part in version_string.split("."):
85+
try:
86+
parts.append(int(part))
87+
except ValueError:
88+
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
89+
# This is a simplification compared to 'packaging.parse_version', but sufficient
90+
# for comparing strictly numeric semantic versions.
91+
break
92+
return tuple(parts)
93+
94+
def _get_version(dependency_name):
95+
try:
96+
version_string: str = metadata.version(dependency_name)
97+
parsed_version = parse_version_to_tuple(version_string)
98+
return (parsed_version, version_string)
99+
except Exception:
100+
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
101+
# or errors during parse_version_to_tuple
102+
return (None, "--")
103+
104+
_dependency_package = "google.protobuf"
105+
_next_supported_version = "6.33.5"
106+
_next_supported_version_tuple = (6, 33, 5)
107+
_recommendation = " (we recommend 7.x)"
108+
(_version_used, _version_used_string) = _get_version(
109+
_dependency_package
110+
)
111+
if _version_used and _version_used < _next_supported_version_tuple:
112+
warnings.warn(
113+
f"Package {_package_label} depends on "
114+
+ f"{_dependency_package}, currently installed at version "
115+
+ f"{_version_used_string}. Future updates to "
116+
+ f"{_package_label} will require {_dependency_package} at "
117+
+ f"version {_next_supported_version} or higher{_recommendation}."
118+
+ " Please ensure "
119+
+ "that either (a) your Python environment doesn't pin the "
120+
+ f"version of {_dependency_package}, so that updates to "
121+
+ f"{_package_label} can require the higher version, or "
122+
+ "(b) you manually update your Python environment to use at "
123+
+ f"least version {_next_supported_version} of "
124+
+ f"{_dependency_package}.",
125+
FutureWarning,
126+
)
127+
except Exception:
128+
warnings.warn(
129+
"Could not determine the version of Python "
130+
+ "currently being used. To continue receiving "
131+
+ "updates for {_package_label}, ensure you are "
132+
+ "using a supported version of Python; see "
133+
+ "https://devguide.python.org/versions/"
134+
)
135+
136+
__all__ = (
137+
"BookCampaignsOperation",
138+
"BookCampaignsResult",
139+
"GenerateShareablePreviewsOperation",
140+
"GenerateShareablePreviewsResult",
141+
"QuoteCampaignsOperation",
142+
"QuoteCampaignsResult",
143+
"ShareablePreview",
144+
"ShareablePreviewResult",
145+
"UiPreviewResult",
146+
"YouTubeLivePreviewResult",
147+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
Lines changed: 44 additions & 0 deletions

0 commit comments

Comments
 (0)