File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -154,7 +154,8 @@ def main(argv: Sequence[str] | None = None):
154154 break
155155
156156 for failure in failures :
157- print (f"{ failure } \n " )
157+ failure .print ()
158+ print ()
158159
159160 if failures :
160161 print (f"""\
Original file line number Diff line number Diff line change 88from textwrap import dedent
99
1010import yaml
11+ from rich .console import Console
12+ from rich .syntax import Syntax
1113
1214from postprocess .cache import AbstractCache
1315from postprocess .definitions import (
@@ -87,7 +89,7 @@ def header(self) -> str:
8789 )
8890
8991 def diff (self ) -> str :
90- diff = "" .join (
92+ return "" .join (
9193 unified_diff (
9294 a = [f"{ comment } \n " for comment in self .c_comments ],
9395 b = [f"{ comment } \n " for comment in self .rust_comments ],
@@ -96,13 +98,23 @@ def diff(self) -> str:
9698 tofile = f"{ self .prompt .rust_source_file } :{ self .prompt .identifier } " ,
9799 )
98100 ).rstrip ()
101+
102+ def __str__ (self ) -> str :
99103 return f"""\
104+ { self .header ()}
105+
100106```diff
101- { diff }
107+ { self . diff () }
102108```"""
103109
104- def __str__ (self ) -> str :
105- return f"{ self .header ()} \n \n { self .diff ()} "
110+ def print (self ):
111+ console = Console ()
112+ console .print (f"""\
113+ { self .header ()}
114+
115+ ```diff""" )
116+ console .print (Syntax (self .diff (), "diff" ))
117+ console .print ("```" )
106118
107119 @staticmethod
108120 def to_exclude_file (failures : Iterable ["CommentTransferFailure" ]) -> str :
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ dependencies = [
99 " platformdirs>=4.5.1" ,
1010 " pygments>=2.19.2" ,
1111 " pyyaml>=6.0.3" ,
12+ " rich>=14.2.0" ,
1213 " tomli>=2.3.0" ,
1314 " tomlkit>=0.13.3" ,
1415 " tree-sitter>=0.25.2" ,
You can’t perform that action at this time.
0 commit comments