Skip to content

Commit 5c54da8

Browse files
committed
Fix: Include the module path when diffing python code
1 parent ab09f9b commit 5c54da8

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

sqlmesh/core/model/common.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,16 @@ def sort_python_env(python_env: t.Dict[str, Executable]) -> t.List[t.Tuple[str,
361361

362362
def sorted_python_env_payloads(python_env: t.Dict[str, Executable]) -> t.List[str]:
363363
"""Returns the payloads of the sorted python env."""
364-
return [
365-
v.payload if v.is_import or v.is_definition else f"{k} = {v.payload}"
366-
for k, v in sort_python_env(python_env)
367-
]
364+
365+
def _executable_to_str(k: str, v: Executable) -> str:
366+
result = f"# {v.path}\n" if v.path is not None else ""
367+
if v.is_import or v.is_definition:
368+
result += v.payload
369+
else:
370+
result += f"{k} = {v.payload}"
371+
return result
372+
373+
return [_executable_to_str(k, v) for k, v in sort_python_env(python_env)]
368374

369375

370376
expression_validator: t.Callable = field_validator(

0 commit comments

Comments
 (0)