Skip to content

gh-144812: Make argparse group classes public - #158045

Open
gaborbernat wants to merge 1 commit into
python:mainfrom
gaborbernat:gh-144812-public-argparse-groups
Open

gaborbernat wants to merge 1 commit into
python:mainfrom
gaborbernat:gh-144812-public-argparse-groups

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Following @savannahostrowski's suggestion on the issue, this makes ArgumentGroup and MutuallyExclusiveGroup public and keeps _ArgumentGroup and _MutuallyExclusiveGroup as aliases, since existing code imports them.

The docs cover what they already promised: the objects that add_argument_group() and add_mutually_exclusive_group() return, and their add_argument() and add_mutually_exclusive_group() methods. The constructors stay implementation details.

This replaces the protocol approach from #150597.

Code that annotates the return values of add_argument_group() and
add_mutually_exclusive_group() has to import the private _ArgumentGroup and
_MutuallyExclusiveGroup today. Public names give that code a supported type,
and the old names stay as aliases so existing imports keep working.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34728555 | 📁 Comparing cbdacbf against main (6893326)

  🔍 Preview build  

3 files changed
± library/argparse.html
± whatsnew/3.16.html
± whatsnew/changelog.html

@gaborbernat

Copy link
Copy Markdown
Contributor Author

@savannahostrowski would you be able to take a look here? Thank you. ❤️

@savannahostrowski

Copy link
Copy Markdown
Member

@gaborbernat Sorry for the delay, I'm hoping to take a look at this in the coming week! Thanks for the ping!

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