Skip to content

Commit 66475a2

Browse files
committed
Add 'Difflib' theme
1 parent 7c31749 commit 66475a2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/_colorize.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ class Unittest(ThemeSection):
207207
reset: str = ANSIColors.RESET
208208

209209

210+
@dataclass(frozen=True)
211+
class Difflib(ThemeSection):
212+
"""A 'git diff'-like theme for `difflib.unified_diff`."""
213+
header: str = ANSIColors.BOLD # eg "---" and "+++" lines
214+
hunk: str = ANSIColors.CYAN # the "@@" lines
215+
insert: str = ANSIColors.GREEN
216+
delete: str = ANSIColors.RED
217+
reset: str = ANSIColors.RESET
218+
219+
210220
@dataclass(frozen=True)
211221
class Theme:
212222
"""A suite of themes for all sections of Python.
@@ -218,6 +228,7 @@ class Theme:
218228
syntax: Syntax = field(default_factory=Syntax)
219229
traceback: Traceback = field(default_factory=Traceback)
220230
unittest: Unittest = field(default_factory=Unittest)
231+
difflib: Difflib = field(default_factory=Difflib)
221232

222233
def copy_with(
223234
self,
@@ -226,6 +237,7 @@ def copy_with(
226237
syntax: Syntax | None = None,
227238
traceback: Traceback | None = None,
228239
unittest: Unittest | None = None,
240+
difflib: Difflib | None = None,
229241
) -> Self:
230242
"""Return a new Theme based on this instance with some sections replaced.
231243
@@ -237,6 +249,7 @@ def copy_with(
237249
syntax=syntax or self.syntax,
238250
traceback=traceback or self.traceback,
239251
unittest=unittest or self.unittest,
252+
difflib=difflib or self.difflib,
240253
)
241254

242255
@classmethod
@@ -252,6 +265,7 @@ def no_colors(cls) -> Self:
252265
syntax=Syntax.no_colors(),
253266
traceback=Traceback.no_colors(),
254267
unittest=Unittest.no_colors(),
268+
difflib=Difflib.no_colors(),
255269
)
256270

257271

0 commit comments

Comments
 (0)