Skip to content
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

GH-127133: Remove ability to nest argument groups and mutex groups #127186

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

savannahostrowski
Copy link
Member

@savannahostrowski savannahostrowski commented Nov 23, 2024

This PR removes the ability to:

  • Call add_argument_group on an argument group
  • Call add_argument_group or add_mutually_exclusive_group on a mutually exclusive group

We have been warning users of this deprecation since 3.11.


📚 Documentation preview 📚: https://cpython-previews--127186.org.readthedocs.build/

Lib/argparse.py Outdated
)
return super().add_argument_group(*args, **kwargs)

raise ValueError('nested argument groups are not supported')
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is the right error type but let me know if there's a more appropriate type.

@savannahostrowski
Copy link
Member Author

@iritkatriel Perhaps you can take a look at this one if you've got bandwidth, since you added the original deprecation warnings ☺️

@savannahostrowski
Copy link
Member Author

savannahostrowski commented Nov 23, 2024

Hmm, let me double-check that there aren't other formatting simplifications we can make now as a result of dropping this.

I took a look and ran branch coverage with a couple of different programs, and nothing stood out to me, so I think it's fine to proceed with this and then tackle any other potential refactorings in separate PRs.

@savannahostrowski savannahostrowski marked this pull request as ready for review November 23, 2024 06:06
Lib/test/test_argparse.py Outdated Show resolved Hide resolved
Lib/argparse.py Outdated Show resolved Hide resolved
Lib/argparse.py Outdated Show resolved Hide resolved
Doc/library/argparse.rst Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants