gh-143984: Improve Lib/test/test_decimal.py CLI with argparse#143983
gh-143984: Improve Lib/test/test_decimal.py CLI with argparse#143983tonghuaroot wants to merge 6 commits intopython:mainfrom
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
…mal.py The optparse module is deprecated since Python 3.2. This change migrates Lib/test/test_decimal.py to use the argparse module for command line argument parsing. This involves: - Importing argparse instead of optparse. - Using ArgumentParser instead of OptionParser. - Updating argument definitions (add_argument). - Escaping '%' characters in help strings. - Updating execution logic to use the argparse Namespace object.
24d59b9 to
5fee791
Compare
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Misc/NEWS.d/next/Tests/2026-01-18-05-42-41.gh-issue-143984.n1imyc.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
…myc.rst Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
ZeroIntensity
left a comment
There was a problem hiding this comment.
I am very concerned that this will inspire copycat PRs. optparse is not deprecated, so apart from "this isn't optparse", what's the benefit of switching?
|
argparse has a better user experience with mutually exclusive groups and colour help. |
|
Ok, that's fine. I think we should be clearer about that in the issue and news entry. So, instead of saying "replaced |
|
Updated the NEWS entry and PR description to highlight the improvements in help output (colorized help, better grouping). Thanks! |
In this case you just specify the usage line to the parser, which is more flexible than any generated output.
What about adding colour help to optparse instead? I do not think this change is needed. This is an internal tool, you run |
Description
This change improves the command-line interface experience, including support for colorized help output and better grouping of arguments.
Verification
python Lib/test/test_decimal.py --helppython Lib/test/test_decimal.py --skip