Skip to content

Commit 3f20ec5

Browse files
committed
fix the shared/local modules in types.py
1 parent bb10b32 commit 3f20ec5

File tree

2 files changed

+64
-17
lines changed

2 files changed

+64
-17
lines changed

tasks/google/cloud/tasks_v2beta2/types.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,34 @@
3333
from google.rpc import status_pb2
3434

3535
names = []
36-
for module in (
37-
http_pb2,
38-
cloudtasks_pb2,
39-
queue_pb2,
40-
target_pb2,
41-
task_pb2,
42-
iam_policy_pb2,
43-
policy_pb2,
44-
any_pb2,
45-
descriptor_pb2,
46-
duration_pb2,
47-
empty_pb2,
48-
field_mask_pb2,
49-
timestamp_pb2,
50-
status_pb2,
51-
):
36+
_shared_modules = [
37+
http_pb2,
38+
iam_policy_pb2,
39+
policy_pb2,
40+
any_pb2,
41+
descriptor_pb2,
42+
duration_pb2,
43+
empty_pb2,
44+
field_mask_pb2,
45+
timestamp_pb2,
46+
status_pb2,
47+
]
48+
49+
_local_modules = [
50+
cloudtasks_pb2,
51+
queue_pb2,
52+
target_pb2,
53+
task_pb2,
54+
]
55+
56+
for module in _shared_modules:
5257
for name, message in get_messages(module).items():
53-
message.__module__ = 'google.cloud.tasks_v2beta2.types'
5458
setattr(sys.modules[__name__], name, message)
5559
names.append(name)
5660

61+
for module in _local_modules:
62+
for name, message in get_messages(module).items():
63+
message.__module__ = 'google.cloud.tasks_v2beta2.types'
64+
setattr(sys.modules[__name__], name, message)
65+
5766
__all__ = tuple(sorted(names))

tasks/synth.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,41 @@
8282
"\g<1>if hasattr(\g<5>, 'name'):\n"
8383
"\g<1> \g<2>\g<3> \g<4>\g<5>\g<6> \g<7>"
8484
)
85+
86+
87+
# fix the combined shared/local modules.
88+
# https://github.com/GoogleCloudPlatform/google-cloud-python/pull/5364
89+
# https://github.com/googleapis/gapic-generator/issues/2058
90+
s.replace(
91+
"google/cloud/*/types.py",
92+
"for module in \(\n(.*\n)*?\):\n( .*\n)+",
93+
"""_shared_modules = [
94+
http_pb2,
95+
iam_policy_pb2,
96+
policy_pb2,
97+
any_pb2,
98+
descriptor_pb2,
99+
duration_pb2,
100+
empty_pb2,
101+
field_mask_pb2,
102+
timestamp_pb2,
103+
status_pb2,
104+
]
105+
106+
_local_modules = [
107+
cloudtasks_pb2,
108+
queue_pb2,
109+
target_pb2,
110+
task_pb2,
111+
]
112+
113+
for module in _shared_modules:
114+
for name, message in get_messages(module).items():
115+
setattr(sys.modules[__name__], name, message)
116+
names.append(name)
117+
118+
for module in _local_modules:
119+
for name, message in get_messages(module).items():
120+
message.__module__ = 'google.cloud.tasks_v2beta2.types'
121+
setattr(sys.modules[__name__], name, message)
122+
""")

0 commit comments

Comments
 (0)