Skip to content

Commit e5f8e13

Browse files
committed
fix(generator): only generate _compat.py if API schema contains auto_populated_fields
1 parent 142d337 commit e5f8e13

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

packages/gapic-generator/gapic/generator/generator.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ def _render_template(
266266
if not opts.metadata and template_name.endswith("gapic_metadata.json.j2"):
267267
return answer
268268

269+
# Only render _compat.py.j2 if the API schema has auto_populated_fields
270+
if template_name.endswith("_compat.py.j2"):
271+
has_auto_populated = any(
272+
m_settings and getattr(m_settings, "auto_populated_fields", None)
273+
for m_settings in api_schema.all_method_settings.values()
274+
)
275+
if not has_auto_populated:
276+
return answer
277+
278+
269279
# Disables generation of an unversioned Python package for this client
270280
# library. This means that the module names will need to be versioned in
271281
# import statements. For example `import google.cloud.library_v2` instead

0 commit comments

Comments
 (0)