Skip to content

Commit 286f3d9

Browse files
authored
Changes for Q12025 Release (#915)
Migrate setup.py file to a pyproject.toml file Add support for Python 3.13 and remove support for 3.8 Fix bug in upload_offline_conversion example. Update library to support default gapic templates. Regen v17, v18, and v19 with default templates. Remove v16.
1 parent af04986 commit 286f3d9

File tree

6,549 files changed

+624973
-301670
lines changed

Some content is hidden

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

6,549 files changed

+624973
-301670
lines changed

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ You can manually run the formatter on all non-generated code with the following
4343
command:
4444

4545
```
46-
python -m black -l 80 -t py37 --exclude "/(v[0-9]+|\.eggs|\.git|_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist)/" .
46+
python -m black -l 80 --exclude "/(v[0-9]+|\.eggs|\.git|_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist)/" .
4747
```
4848

4949
Alternatively, if you intend to contribute regularly, it might be easier to
5050
append this script to the `.git/hooks/pre-commit` file:
5151

5252
```
5353
FILES=$(git diff --cached --name-only --diff-filter=ACMR "*.py" | grep -v "google/ads/google_ads/v.*")
54-
echo "${FILES}" | xargs python -m black -l 80 -t py37
54+
echo "${FILES}" | xargs python -m black -l 80
5555
echo "${FILES}" | xargs git add
5656
```

ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
* 26.0.0
2+
- Migrate to default GAPIC templates
3+
- Migrate from setup.py to pyproject.toml
4+
- Remove Google Ads API v16
5+
- Add support for Python 3.13
6+
- Remove support for Python 3.8
7+
18
* 25.2.0
29
- Google Ads API v19 release.
310

examples/remarketing/upload_offline_conversion.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ def main(
134134

135135

136136
if __name__ == "__main__":
137+
# GoogleAdsClient will read the google-ads.yaml configuration file in the
138+
# home directory if none is specified.
139+
googleads_client = GoogleAdsClient.load_from_storage(version="v19")
140+
137141
parser = argparse.ArgumentParser(
138142
description="Uploads an offline conversion."
139143
)
@@ -225,10 +229,6 @@ def main(
225229
)
226230
args = parser.parse_args()
227231

228-
# GoogleAdsClient will read the google-ads.yaml configuration file in the
229-
# home directory if none is specified.
230-
googleads_client = GoogleAdsClient.load_from_storage(version="v19")
231-
232232
try:
233233
main(
234234
googleads_client,

google/ads/googleads/__init__.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,4 @@
1919
import google.ads.googleads.errors
2020
import google.ads.googleads.util
2121

22-
VERSION = "25.2.0"
23-
24-
if sys.version_info.major == 3 and sys.version_info.minor <= 8:
25-
warnings.warn(
26-
"Python versions 3.8 and below will soon be deprecated in the "
27-
"google-ads package. Please upgrade to Python 3.9 or higher as soon as "
28-
"possible.",
29-
category=DeprecationWarning,
30-
)
22+
VERSION = "26.0.0"

google/ads/googleads/client.py

+29-17
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131

3232
_SERVICE_CLIENT_TEMPLATE = "{}Client"
3333

34-
_VALID_API_VERSIONS = ["v19", "v18", "v17", "v16"]
34+
_VALID_API_VERSIONS = ["v19", "v18", "v17"]
35+
_MESSAGE_TYPES = ["common", "enums", "errors", "resources", "services"]
3536
_DEFAULT_VERSION = _VALID_API_VERSIONS[0]
3637

3738
# Retrieve the version of this client library to be sent in the user-agent
@@ -357,14 +358,17 @@ def get_service(self, name, version=_DEFAULT_VERSION, interceptors=None):
357358
# If version is specified when the instance is created,
358359
# override any version specified as an argument.
359360
version = self.version if self.version else version
360-
api_module = self._get_api_services_by_version(version)
361+
# api_module = self._get_api_services_by_version(version)
362+
services_path = f"google.ads.googleads.{version}.services.services"
363+
snaked = util.convert_upper_case_to_snake_case(name)
361364
interceptors = interceptors or []
362365

363366
try:
364-
service_client_class = getattr(
365-
api_module, _SERVICE_CLIENT_TEMPLATE.format(name)
367+
service_module = import_module(f"{services_path}.{snaked}")
368+
service_client_class = util.get_nested_attr(
369+
service_module, _SERVICE_CLIENT_TEMPLATE.format(name)
366370
)
367-
except AttributeError:
371+
except (AttributeError, ModuleNotFoundError):
368372
raise ValueError(
369373
'Specified service {}" does not exist in Google '
370374
"Ads API {}.".format(name, version)
@@ -438,17 +442,25 @@ def get_type(self, name, version=_DEFAULT_VERSION):
438442
# If version is specified when the instance is created,
439443
# override any version specified as an argument.
440444
version = self.version if self.version else version
445+
type_classes = self._get_api_services_by_version(version)
441446

442-
try:
443-
type_classes = self._get_api_services_by_version(version)
444-
message_class = getattr(type_classes, name)
445-
except AttributeError:
446-
raise ValueError(
447-
f"Specified type '{name}' does not exist in "
448-
f"Google Ads API {version}"
449-
)
447+
for type in _MESSAGE_TYPES:
448+
if type == "services":
449+
path = f"{type}.types.{name}"
450+
else:
451+
path = f"{type}.{name}"
450452

451-
if self.use_proto_plus == True:
452-
return message_class()
453-
else:
454-
return util.convert_proto_plus_to_protobuf(message_class())
453+
try:
454+
message_class = util.get_nested_attr(type_classes, path)
455+
456+
if self.use_proto_plus == True:
457+
return message_class()
458+
else:
459+
return util.convert_proto_plus_to_protobuf(message_class())
460+
except AttributeError:
461+
pass
462+
463+
raise ValueError(
464+
f"Specified type '{name}' does not exist in "
465+
f"Google Ads API {version}"
466+
)

0 commit comments

Comments
 (0)