1919from sqlmesh .core import constants as c
2020from sqlmesh .core .console import get_console
2121from sqlmesh .core .macros import RuntimeStage
22- from sqlmesh .core .model .common import python_env_payloads
22+ from sqlmesh .core .model .common import sorted_python_env_payloads
2323from sqlmesh .core .snapshot import Snapshot , SnapshotId , SnapshotTableInfo
2424from sqlmesh .utils .errors import SQLMeshError
2525from sqlmesh .utils .pydantic import PydanticModel
@@ -337,27 +337,22 @@ def extract_statements(statements: t.List[EnvironmentStatements], attr: str) ->
337337 expr
338338 for statement in statements
339339 for expr in (
340- python_env_payloads (
341- sorted (statement .python_env .items (), key = lambda x : (x [1 ].kind , x [0 ]))
342- )
340+ sorted_python_env_payloads (statement .python_env )
343341 if attr == "python_env"
344342 else getattr (statement , attr )
345343 )
346344 ]
347345
348- def format_diff (attribute : str ) -> t .Optional [t .Tuple [str , str ]]:
346+ def compute_diff (attribute : str ) -> t .Optional [t .Tuple [str , str ]]:
349347 previous = extract_statements (self .previous_environment_statements , attribute )
350348 current = extract_statements (self .environment_statements , attribute )
351349
352350 if previous == current :
353351 return None
354352
355353 diff_lines = list (ndiff (previous , current ))
356- diff_text = (
357- f"=== { attribute } ===\n "
358- if not attribute == "python_env"
359- else "=== dependencies ===\n "
360- )
354+ diff_text = attribute if not attribute == "python_env" else "dependencies"
355+ diff_text += ":\n "
361356
362357 if any (line .startswith (("-" , "+" )) for line in diff_lines ):
363358 diff_text += " " + "\n " .join (diff_lines ) + "\n "
@@ -371,7 +366,7 @@ def format_diff(attribute: str) -> t.Optional[t.Tuple[str, str]]:
371366 RuntimeStage .AFTER_ALL .value ,
372367 "python_env" ,
373368 ]
374- if (diff := format_diff (attribute )) is not None
369+ if (diff := compute_diff (attribute )) is not None
375370 ]
376371
377372 @property
0 commit comments