Explorar el Código

style: fix linting issues in template.py

- Combine nested if statements
- Extract magic number to named variable
- Break long line for better readability
- All ruff checks passing

Co-authored-by: ChristianLempa <28359525+ChristianLempa@users.noreply.github.com>
copilot-swe-agent[bot] hace 3 meses
padre
commit
eae3edd8f9
Se han modificado 1 ficheros con 17 adiciones y 14 borrados
  1. 17 14
      cli/core/template/template.py

+ 17 - 14
cli/core/template/template.py

@@ -505,20 +505,23 @@ class Template:
         # These are the problematic ones - the template relies on schema
         missing_definitions = (used_vars & module_vars) - template_vars
 
-        if missing_definitions:
-            # Only warn once per template (use a flag to avoid repeated warnings)
-            if not hasattr(self, "_schema_deprecation_warned"):
-                self._schema_deprecation_warned = True
-                logger.warning(
-                    f"DEPRECATION WARNING: Template '{self.id}' uses {len(missing_definitions)} "
-                    f"variable(s) from module schema without defining them in template.yaml. "
-                    f"In future versions, all used variables must be defined in template.yaml. "
-                    f"Missing definitions: {', '.join(sorted(list(missing_definitions)[:10]))}{'...' if len(missing_definitions) > 10 else ''}"
-                )
-                logger.debug(
-                    f"Template '{self.id}' should add these variable definitions to template.yaml spec: "
-                    f"{sorted(missing_definitions)}"
-                )
+        # Only warn once per template (use a flag to avoid repeated warnings)
+        if missing_definitions and not hasattr(self, "_schema_deprecation_warned"):
+            self._schema_deprecation_warned = True
+            # Show first N variables in warning, full list in debug
+            max_shown_vars = 10
+            shown_vars = sorted(list(missing_definitions)[:max_shown_vars])
+            ellipsis = "..." if len(missing_definitions) > max_shown_vars else ""
+            logger.warning(
+                f"DEPRECATION WARNING: Template '{self.id}' uses {len(missing_definitions)} "
+                f"variable(s) from module schema without defining them in template.yaml. "
+                f"In future versions, all used variables must be defined in template.yaml. "
+                f"Missing definitions: {', '.join(shown_vars)}{ellipsis}"
+            )
+            logger.debug(
+                f"Template '{self.id}' should add these variable definitions to template.yaml spec: "
+                f"{sorted(missing_definitions)}"
+            )
 
     def _collect_template_files(self) -> None:
         """Collects all TemplateFile objects in the template directory."""