PR review: Fix argparse namespace overridden

Hi, I have a PR open for nearly one year.

It is to fix an issue: gh-89398. Can anyone kindly review and possibly merge this? There is already a basic review by Jelle Zijlstra

I have a feeling that your PR is not getting merged because argparse is poorly specified and for every unexpected behavior that you would like to fix there seems to be a user who actually relies on the current behavior and whose code will be broken by the fix. IIRC in the not so distant past we’ve had to retract some argparse fixes for this reason, so everybody is wary of making changes.


I agree that’s the problem, especially with subparsers. Personally, after looking at Issue 9334: argparse does not accept options taking arguments beginning with dash (regression from optparse) - Python tracker for 10 years, I think argparse’s design is just broken. I no longer use it, and have stopped looking at bug reports for it.

It would be nice to deprecate it and move it to PyPI where it could evolve, but I’m not sure who would take ownership. So it will probably sit in the stdlib forever, not getting much attention.


We could still deprecate it even if we don’t have any plans to remove it.

I’m hoping to bring up stdlib guidelines/maintenance/whatever at the language summit in April.

I think argparse’s design is just broken. I no longer use it, and have stopped looking at bug reports for it.

Ouch. The main thing I work on is still using optparse, mainly because argparse and the (officially deprecated) optparse are broken in disjoint enough ways that the conversion is more painful than anyone’s been willing to sign up for. I’ve kind of been kicking myself for not working up that enthusiasm, but now…

Is it a given that the stdlib must have a cli-parsing module? There are three at the moment, and a multitude of non-stdlib projects that are sure they solve the problem the One True Way. Different choices are not necessarily a problem, but this feels more confusing than it needs to be.

This does sort of feel like a topic that could be brought up at a language summit - is there anything that’s worthwhile to discuss in the meantime?

That’s one of the questions to ask about the purpose and future of the stdlib as there’s no agreed-upon answer to that as we have no guidelines around the stdlib.

We will never remove any of the CLI parsing libraries in the stdlib because they are all being actively used.


So I can go back to my comfy getopt module? :wink:

For us UNIX-y types, that’s fine :slight_smile:

Disclaimer: this is going to sound snarky, actually meant to be silly:

There should be one-- and preferably only one --obvious way to do it.

… except for command-line parsing, where there are three included ways to do it, all suboptimal. But hey, there are lots of other ways on PyPI, or you could roll your own, so nothing confusing there.

1 Like

Exactly, this PR is to fix the same issue with a more careful implementation.

I totally agree with the concerns and accept the decision to not touch this module. Thanks.

1 Like

I just can’t review it.