Skip to content

gh-149461: argparse: Implement subnamespace feature#149462

Closed
jb2170 wants to merge 8 commits intopython:mainfrom
jb2170:argparse-subnamespace
Closed

gh-149461: argparse: Implement subnamespace feature#149462
jb2170 wants to merge 8 commits intopython:mainfrom
jb2170:argparse-subnamespace

Conversation

@jb2170
Copy link
Copy Markdown
Contributor

@jb2170 jb2170 commented May 6, 2026

jb2170 added 8 commits May 6, 2026 15:53
…ation name

Like in `_ActionsContainer._get_optional_kwargs`. It makes it much
easier to access the subnamespaces by `x.y` instead of needing
`getattr(x, 'y')` in the case that y (the subparser choice) has hyphens
in it.
I've tried to be in depth, and the tests are commented. Comments can be
removed later if one wants, but they're in the git history here for the
record.
…_SubParsersAction.add_parser`

Instead of it being mixed into kwargs, we keep 'subnamespace' separate
like 'deprecated'.

This makes it clearer that 'subnamespace' isn't intended as a parameter
to be passed to the subparser constructor.
Commit to mark last version in which 'subnamespace' is a string
indicating where a subNamespace should be stored in its parent
Namespace.

We're changing over to using a 'bool' instead, and letting the
subnamespace destination be determined by the subparser name
automatically.

I don't need a git tag for this, just a commit.
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32566372 | 📁 Comparing a879304 against main (4ed4014)

  🔍 Preview build  

6 files changed · ± 6 modified

± Modified

@picnixz
Copy link
Copy Markdown
Member

picnixz commented May 6, 2026

Closing as per the issue's rationale. We do not have a consensus yet.

@picnixz picnixz closed this May 6, 2026
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