-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-133722: Add Difflib theme to _colorize
and 'color' option to difflib.unified_diff
#133725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
5c5b248
fdc0fa0
fcdd7ab
0e9b070
7c31749
66475a2
dbf0547
a72012e
2a3d818
252982e
3422fa7
bffdd71
3255866
c48a6ac
8ca50fa
eb0e81e
f7b34c3
fb092b0
734b0bc
8a10e40
57b80d1
c235425
387cfe6
833d86a
25f9d80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -207,6 +207,16 @@ class Unittest(ThemeSection): | |||||||||||||||||
reset: str = ANSIColors.RESET | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
@dataclass(frozen=True) | ||||||||||||||||||
class Difflib(ThemeSection): | ||||||||||||||||||
"""A 'git diff'-like theme for `difflib.unified_diff`.""" | ||||||||||||||||||
header: str = ANSIColors.BOLD # eg "---" and "+++" lines | ||||||||||||||||||
hunk: str = ANSIColors.CYAN # the "@@" lines | ||||||||||||||||||
insert: str = ANSIColors.GREEN | ||||||||||||||||||
delete: str = ANSIColors.RED | ||||||||||||||||||
reset: str = ANSIColors.RESET | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
@dataclass(frozen=True) | ||||||||||||||||||
class Theme: | ||||||||||||||||||
"""A suite of themes for all sections of Python. | ||||||||||||||||||
|
@@ -218,6 +228,7 @@ class Theme: | |||||||||||||||||
syntax: Syntax = field(default_factory=Syntax) | ||||||||||||||||||
traceback: Traceback = field(default_factory=Traceback) | ||||||||||||||||||
unittest: Unittest = field(default_factory=Unittest) | ||||||||||||||||||
difflib: Difflib = field(default_factory=Difflib) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm very slightly concerned about sorting when the dataclasses aren't Should I update the dataclass decorator to include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's ask @ambv about this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this suggestion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Done |
||||||||||||||||||
|
||||||||||||||||||
def copy_with( | ||||||||||||||||||
self, | ||||||||||||||||||
|
@@ -226,6 +237,7 @@ def copy_with( | |||||||||||||||||
syntax: Syntax | None = None, | ||||||||||||||||||
traceback: Traceback | None = None, | ||||||||||||||||||
unittest: Unittest | None = None, | ||||||||||||||||||
difflib: Difflib | None = None, | ||||||||||||||||||
dougthor42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
) -> Self: | ||||||||||||||||||
"""Return a new Theme based on this instance with some sections replaced. | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -237,6 +249,7 @@ def copy_with( | |||||||||||||||||
syntax=syntax or self.syntax, | ||||||||||||||||||
traceback=traceback or self.traceback, | ||||||||||||||||||
unittest=unittest or self.unittest, | ||||||||||||||||||
difflib=difflib or self.difflib, | ||||||||||||||||||
dougthor42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
@classmethod | ||||||||||||||||||
|
@@ -252,6 +265,7 @@ def no_colors(cls) -> Self: | |||||||||||||||||
syntax=Syntax.no_colors(), | ||||||||||||||||||
traceback=Traceback.no_colors(), | ||||||||||||||||||
unittest=Unittest.no_colors(), | ||||||||||||||||||
difflib=Difflib.no_colors(), | ||||||||||||||||||
dougthor42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.