Skip to content

Conversation

@tonghuaroot
Copy link

@tonghuaroot tonghuaroot commented Jan 18, 2026

Description

This change improves the command-line interface experience, including support for colorized help output and better grouping of arguments.

Verification

  • Run python Lib/test/test_decimal.py --help
  • Run python Lib/test/test_decimal.py --skip

@bedevere-app
Copy link

bedevere-app bot commented Jan 18, 2026

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 skip news label instead.

@bedevere-app bedevere-app bot added tests Tests in the Lib/test dir awaiting review labels Jan 18, 2026
@bedevere-app
Copy link

bedevere-app bot commented Jan 18, 2026

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 skip news label instead.

…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.
@tonghuaroot tonghuaroot changed the title Modernize Lib/test/test_decimal.py: use argparse instead of optparse gh-143984: Replace optparse with argparse in Lib/test/test_decimal.py Jan 18, 2026
@bedevere-app
Copy link

bedevere-app bot commented Jan 18, 2026

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 skip news label instead.

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@hugovk
Copy link
Member

hugovk commented Jan 18, 2026

argparse has a better user experience with mutually exclusive groups and colour help.

@ZeroIntensity
Copy link
Member

Ok, that's fine. I think we should be clearer about that in the issue and news entry. So, instead of saying "replaced optparse", how about we say "Added colo(u)r to test_decimal" or something like that?

@tonghuaroot tonghuaroot changed the title gh-143984: Replace optparse with argparse in Lib/test/test_decimal.py gh-143984: Improve Lib/test/test_decimal.py CLI with argparse Jan 18, 2026
@tonghuaroot
Copy link
Author

Updated the NEWS entry and PR description to highlight the improvements in help output (colorized help, better grouping). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants