From dba5f631ca674a079e694b4a9cb7b84ee3ec553c Mon Sep 17 00:00:00 2001 From: David Wihl Date: Thu, 26 Dec 2019 10:29:54 -0500 Subject: [PATCH] Release 4.1.1 (#198) --- ChangeLog | 3 +++ google/ads/google_ads/__init__.py | 2 +- google/ads/google_ads/v2/types.py | 29 +++++++++++++++++++++++++++-- setup.py | 2 +- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a2887d49..1941ef6a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +* 4.1.1: +- Fix for types.py to include classes of dependent modules + * 4.1.0: - Performance improvements - Updated dependencies for more recent versions diff --git a/google/ads/google_ads/__init__.py b/google/ads/google_ads/__init__.py index 3601b807b..ef17c286b 100644 --- a/google/ads/google_ads/__init__.py +++ b/google/ads/google_ads/__init__.py @@ -20,4 +20,4 @@ import google.ads.google_ads.util -VERSION = '4.1.0' +VERSION = '4.1.1' diff --git a/google/ads/google_ads/v2/types.py b/google/ads/google_ads/v2/types.py index 386f676be..83350c543 100644 --- a/google/ads/google_ads/v2/types.py +++ b/google/ads/google_ads/v2/types.py @@ -18,6 +18,7 @@ import importlib import re import sys +from inspect import getmembers, isclass from itertools import chain from google.api_core.protobuf_helpers import get_messages @@ -1626,6 +1627,27 @@ YoutubeVideoRegistrationErrorEnum='google.ads.google_ads.v2.proto.errors.youtube_video_registration_error_pb2' ) +DEPENDENT_MODULE_LIST = [ + 'google.longrunning.operations_pb2', + 'google.protobuf.any_pb2', + 'google.protobuf.empty_pb2', + 'google.protobuf.field_mask_pb2', + 'google.protobuf.wrappers_pb2', + 'google.rpc.status_pb2'] + +def _get_class_from_module(module_name): + module = importlib.import_module(module_name) + for class_name, _ in getmembers(module, isclass): # from inspect module + yield class_name + +def _populate_dependent_classes(module_list = DEPENDENT_MODULE_LIST): + class_list = {} + for module_name in module_list: + for cls in _get_class_from_module(module_name): + class_list[cls] = module_name + return class_list + +_lazy_dependent_class_to_package_map = _populate_dependent_classes() def _load_module(module_name): """Load a module by it's name. @@ -1683,7 +1705,9 @@ def _get_message_class_by_name(class_name): a protobuf message class definition that inherits from google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType. """ - if class_name in _lazy_class_to_package_map: + if class_name in _lazy_dependent_class_to_package_map: + module_path = _lazy_dependent_class_to_package_map[class_name] + elif class_name in _lazy_class_to_package_map: module_path = _lazy_class_to_package_map[class_name] else: raise AttributeError(f'unknown sub-module {class_name!r}.') @@ -1707,7 +1731,8 @@ def __getattr__(name): # Requires Python >= 3.7 if name == '__all__': converted = (util.convert_snake_case_to_upper_case(key) for key in chain(_lazy_name_to_package_map, - _lazy_class_to_package_map)) + _lazy_class_to_package_map, + _lazy_dependent_class_to_package_map)) all_names = sorted(converted) globals()['__all__'] = all_names return all_names diff --git a/setup.py b/setup.py index 635404568..4eca0240e 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ setup( name='google-ads', - version='4.1.0', + version='4.1.1', author='Google LLC', author_email='googleapis-packages@google.com', classifiers=[