Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-99749: Add closest choice if exists in Argparser if wrong choice picked#99773
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
ef8e4fc7e8dcf88c754cd4fb8ce62f197b3940a66ebadc5ed2588ef1ee05c1e4a36406fe169bc9fe0d95d12e1c435f0961087895c6eeae5c99656944ef218ae63a01cbfc9262b3b4a9eb8bc465ade070f3753a0dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2193,9 +2193,9 @@ def test_wrong_argument_subparsers_no_destination_error(self): | ||
| subparsers.add_parser('bar') | ||
| with self.assertRaises(ArgumentParserError) as excinfo: | ||
| parser.parse_args(('baz',)) | ||
| self.assertRegex( | ||
| self.assertIn( | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably also want some additional test cases here. | ||
| "error: argument{foo,bar}: invalid choice: 'baz', maybe you meant 'bar'? (choose from 'foo', 'bar')", | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be interested in others' opinions around the verbiage here. It seems like we are using both "Maybe you meant" and "Did you mean" verbiage in the codebase. Not sure if we have any principle around this. | ||
| excinfo.exception.stderr, | ||
| r"error: argument{foo,bar}: invalid choice: 'baz' \(choose from 'foo', 'bar'\)\n$" | ||
| ) | ||
| def test_optional_subparsers(self): | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add closest choice if exists in Argparser if wrong choice picked. |
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.
I think we'd probably want to move the import down into the case where the error is thrown, since this is probably not going to be used very often.