Skip to content

Commit 91b815e

Browse files
minitrigaclaude
andcommitted
Add description field support to InfrahubPythonTransformConfig
Add an optional `description` field to `InfrahubPythonTransformConfig` to achieve parity with `InfrahubJinja2TransformConfig`. This allows users to set descriptions for Python transforms in `.infrahub.yml`. Closes opsmill/infrahub#6382 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b525fef commit 91b815e

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

infrahub_sdk/schema/repository.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class InfrahubPythonTransformConfig(InfrahubRepositoryConfigElement):
128128
default=False,
129129
description="Decide if the transform should convert the result of the GraphQL query to SDK InfrahubNode objects.",
130130
)
131+
description: str | None = Field(default=None, description="Description for this transform")
131132

132133
def load_class(self, import_root: str | None = None, relative_path: str | None = None) -> type[InfrahubTransform]:
133134
module = import_module(module_path=self.file_path, import_root=import_root, relative_path=relative_path)

tests/unit/sdk/test_schema.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,27 @@ async def test_infrahub_repository_config_dups() -> None:
341341
assert "Found multiples element with the same names: ['check01', 'check02']" in str(exc.value)
342342

343343

344+
async def test_python_transform_config_description() -> None:
345+
"""Verify InfrahubPythonTransformConfig supports an optional description field."""
346+
# With description
347+
config_with_desc = InfrahubPythonTransformConfig(
348+
name="my_transform", file_path="transforms/my.py", class_name="MyTransform", description="A useful transform"
349+
)
350+
assert config_with_desc.description == "A useful transform"
351+
352+
# Without description (default None)
353+
config_without_desc = InfrahubPythonTransformConfig(
354+
name="my_transform", file_path="transforms/my.py", class_name="MyTransform"
355+
)
356+
assert config_without_desc.description is None
357+
358+
# Explicit None
359+
config_explicit_none = InfrahubPythonTransformConfig(
360+
name="my_transform", file_path="transforms/my.py", class_name="MyTransform", description=None
361+
)
362+
assert config_explicit_none.description is None
363+
364+
344365
@mock.patch(
345366
"infrahub_sdk.ctl.schema.get_node",
346367
return_value={

0 commit comments

Comments
 (0)