Skip to content

Commit

Permalink
Release 4.1.1 (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
wihl authored Dec 26, 2019
1 parent 6d4d267 commit dba5f63
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion google/ads/google_ads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
import google.ads.google_ads.util


VERSION = '4.1.0'
VERSION = '4.1.1'
29 changes: 27 additions & 2 deletions google/ads/google_ads/v2/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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}.')
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

setup(
name='google-ads',
version='4.1.0',
version='4.1.1',
author='Google LLC',
author_email='[email protected]',
classifiers=[
Expand Down

0 comments on commit dba5f63

Please sign in to comment.