From 2e812fea24179220d6ca11d76e68a08c593bc4fa Mon Sep 17 00:00:00 2001 From: Daiyi Peng Date: Tue, 3 Oct 2023 20:33:32 -0700 Subject: [PATCH] Avoid triggering warnings from accessing `pg.Object.schema`. PiperOrigin-RevId: 570573166 --- langfun/core/template.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/langfun/core/template.py b/langfun/core/template.py index 3a142d1..9d4f5d7 100644 --- a/langfun/core/template.py +++ b/langfun/core/template.py @@ -96,8 +96,9 @@ def __init_subclass__(cls): # Declare template variables as symbolic attributes. template_vars = Template.resolve_vars(template_str) for var_name in template_vars: - var_attr = getattr(cls, var_name, pg.MISSING_VALUE) - if var_attr == pg.MISSING_VALUE: + # NOTE(daiyip): This is to avoid warning from accessing + # `pg.Object.schema`, which was replaced by `pg.Object.__schema__`. + if var_name == 'schema' or not hasattr(cls, var_name): setattr(cls, var_name, component.contextual()) super().__init_subclass__()