From a94a89f38c1b825cc949eda5b46d8ce6f0306490 Mon Sep 17 00:00:00 2001 From: lxcxjxhx Date: Wed, 11 Nov 2026 15:22:07 +0800 Subject: [PATCH] docs(otelcollector): name the parameter that exists, and drop a branch that does not MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All three functions take `output_dir`; the docstrings call it `output_path` and then promise that "if None, the rendered template is only returned". Neither half holds: - the parameter is `output_dir`, and `_render_template` returns `None` — the rendered text is written to a file, never returned; - passing `None` does not fall back to anything. `render_base_config` does `os.path.join(output_dir, "base.yaml")`, which raises TypeError: expected str, bytes or os.PathLike object, not NoneType So the documented "optional" behaviour is a crash. The docstrings now describe what the functions do. Docstrings only: AST comparison against the previous head is identical once docstrings are excluded, and the module compiles. --- .../builder/otelcollector_config/template.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/opentelemetry-collector/builder/otelcollector_config/template.py b/app/opentelemetry-collector/builder/otelcollector_config/template.py index 3a8b7f794..b2d5436c3 100644 --- a/app/opentelemetry-collector/builder/otelcollector_config/template.py +++ b/app/opentelemetry-collector/builder/otelcollector_config/template.py @@ -58,8 +58,7 @@ def _render_template(template_name: str, context: Dict[str, Any], output_dir: st Args: template_name: Name of the template to render context: Dictionary of variables to pass to the template - output_path: Optional path to write the rendered template - If None, the rendered template is only returned + output_dir: Directory to write the rendered template into """ template = renderer.get_template(template_name) output_path = f"{output_dir}/{template_name.replace('.tpl', '')}" @@ -76,8 +75,7 @@ def render_base_config(output_dir: Optional[str] = None) -> None: Render the base configuration template. Args: - output_path: Optional path to write the rendered template. - If None, the rendered template is only returned. + output_dir: Directory to write base.yaml into. """ # wee don't transform this file, so just copy it to the output path shutil.copy( @@ -91,8 +89,7 @@ def render_processors_config(output_dir: Optional[str] = None) -> None: Render the processors.yaml.tpl template with model costs. Args: - output_path: Optional path to write the rendered template. - If None, the rendered template is only returned. + output_dir: Directory to write the rendered template into. """ model_costs: list[ModelCost] = load_model_costs() context = {