-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Enable colored output for argparse help in Python 3.14 #19021
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
Conversation
102b99e
to
3368f64
Compare
This comment has been minimized.
This comment has been minimized.
3368f64
to
634c4d4
Compare
This comment has been minimized.
This comment has been minimized.
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.
This certainly looks nice! Are we sure these changes will be present in final 3.14 release? As usual, there's some chance that unreleased functionality may be removed/renamed/significantly altered.
There is always the possibility that a new feature gets reverted before the final release, though I don't suspect it happening here. Nevertheless if that should happen, a lot of test cases would fail with 3.14 at which point we could just revert this one. |
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.
Thanks for adding this, I think it is a huge readability upgrade to have colors in the help text of a CLI (the reason I proposed #14455 earlier). I have two suggestions for this change:
- Please also change
dmypy
,stubgen
andstubtest
parsers - Instead of branching on the python version and passing a keywords dictionary, set the
color
attribute on the parser instance after initialization, as it is recommended in the argparse documentation.
954cada
to
94052a7
Compare
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Support for colored output was just merged in cpython. Maybe a bit early to add it here already but it doesn't hurt either.
The color output can be disable using various environment variables.
https://docs.python.org/3.14/using/cmdline.html#using-on-controlling-color