-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-133722: Add '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?
Conversation
Thanks for the PR! With the basic theming support in #133347 merged, perhaps we could define a separate difflib theme and use that here? |
@@ -319,6 +322,10 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module. | |||
|
|||
See :ref:`difflib-interface` for a more detailed example. | |||
|
|||
.. versionchanged:: 3.15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. versionchanged:: 3.15 | |
.. versionchanged:: next |
Thanks for the PR! I had a play with something similar but didn't get very far before the 3.14 freeze.
Yes, let's add theming support. See this docstring for instructions. For a couple of standalone examples of adding theme support to a module, see 230d658 and 5c5c3e1 from that PR. |
Ah, TIL! Thanks, I'll take a look at those docs and update accordingly. It'll be a few days a least before I can get to it, so for now I'll revert this back to draft. |
Absolutely no rush for this, we have 12 months until the 3.15 feature freeze. Don't hesitate if you have questions :) |
Add a
color
arg (defaulting toFalse
) todifflib.unified_diff
. WhenTrue
, ANSI color codes are injected to the diff lines so that the printed result looks likegit diff --color
:Fixes #133722.
It's a bummer, I just missed the feature freeze window for 3.14 (it was yesterday! 😭), but c'est la vie!
color: bool
arg todifflib.unified_diff
#133722📚 Documentation preview 📚: https://cpython-previews--133725.org.readthedocs.build/