Просмотр исходного кода

refactor: address code review feedback

- Initialize _schema_deprecation_warned in __init__ instead of hasattr()
- Break down set operations with intermediate variable for clarity
- Makes state management more explicit and predictable
- Improves code readability

Co-authored-by: ChristianLempa <28359525+ChristianLempa@users.noreply.github.com>
copilot-swe-agent[bot] 1 месяц назад
Родитель
Сommit
8a20351682
1 измененных файлов с 6 добавлено и 5 удалено
  1. 6 5
      cli/core/template/template.py

+ 6 - 5
cli/core/template/template.py

@@ -320,6 +320,7 @@ class Template:
         self.__used_variables: set[str] | None = None
         self.__variables: VariableCollection | None = None
         self.__template_files: list[TemplateFile] | None = None  # New attribute
+        self._schema_deprecation_warned: bool = False  # Track if deprecation warning shown
 
         try:
             # Find and parse the main template file (template.yaml or template.yml)
@@ -499,14 +500,14 @@ class Template:
         used_vars = self.used_variables
 
         # Find variables that are:
-        # 1. Used in template files
-        # 2. Defined in module schema
-        # 3. NOT explicitly defined in template.yaml
+        # 1. Used in template files AND defined in module schema (inherited variables)
+        # 2. NOT explicitly defined in template.yaml (missing definitions)
         # These are the problematic ones - the template relies on schema
-        missing_definitions = (used_vars & module_vars) - template_vars
+        inherited_vars = used_vars & module_vars
+        missing_definitions = inherited_vars - template_vars
 
         # Only warn once per template (use a flag to avoid repeated warnings)
-        if missing_definitions and not hasattr(self, "_schema_deprecation_warned"):
+        if missing_definitions and not self._schema_deprecation_warned:
             self._schema_deprecation_warned = True
             # Show first N variables in warning, full list in debug
             max_shown_vars = 10