-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
gh-138525: Support single-dash long options and prefix_chars in BooleanOptionalAction #138692
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-138525: Support single-dash long options and prefix_chars in BooleanOptionalAction #138692
Conversation
fe05304 to
bd8247f
Compare
… BooleanOptionalAction -no-foo is generated for -foo. ++no-foo is generated for ++foo. /no-foo is generated for /foo.
bd8247f to
4fa348b
Compare
|
It seems that programs that use single-dash long options does not usually have a hyphen after "no". |
savannahostrowski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, the implementation here looks good. I've tested it pretty extensively and everything works as expected. We might want to add a test the verifies that single-character options don't get negation variants created (e.g. -n shouldn't get -non).
On a process-related note, I noticed that #138526 was opened earlier for the referenced issue. It might be good to collaborate on existing PRs and/or give this feedback to the contributor (or even ask them if they'd like to try out adding the feature you have in mind). The more robust fix to add this feature isn't too complicated for someone newer to argparse. Might have been a good opportunity to get another active contributor in the module 🙂
This is tested, see the
I opened this PR after seen that PR. As I said in the review, I do not think that approach is correct. |
|
(My objection was to the initial version of #138526, not to the current one. But this PR supersedes it without a need to extend the |
|
-nofoo is generated for -foo.
++no-foo is generated for ++foo.
/nofoo is generated for /foo.
argparse.BooleanOptionalActionsilently failed when used with parser whoseprefix_charshas no'-'#138525📚 Documentation preview 📚: https://cpython-previews--138692.org.readthedocs.build/