- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 33.3k
 
gh-101979: fix a bug that parentheses in metavar argument of add_argument() were dropped #102318
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
Changes from 6 commits
4d68880
              70ef4fc
              da07d8c
              4c6889c
              0dc91c0
              7f82863
              74c14ce
              b05fb16
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| 
          
            
          
           | 
    @@ -3764,6 +3764,28 @@ class TestHelpUsage(HelpTestCase): | |||
| version = '' | ||||
| 
     | 
||||
| 
     | 
||||
| class TestHelpUsageWithParentheses(HelpTestCase): | ||||
| 
         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 don't see any tests that actually add parentheses for a group with more than one action. Could you add one? 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. That's a good idea. But I think the testcase you want already exists using the code below. Please review it. cpython/Lib/test/test_argparse.py Line 2777 in 66aa78c 
 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. You're right, thanks! There are a lot of tests, I must have glanced over that one.  | 
||||
| parser_signature = Sig(prog='PROG') | ||||
| argument_signatures = [ | ||||
| Sig('positional', metavar='(example) positional'), | ||||
| Sig('-p', '--optional', metavar='{1 (option A), 2 (option B)}'), | ||||
| ] | ||||
| 
     | 
||||
| usage = '''\ | ||||
| usage: PROG [-h] [-p {1 (option A), 2 (option B)}] (example) positional | ||||
| ''' | ||||
| help = usage + '''\ | ||||
| 
     | 
||||
| positional arguments: | ||||
| (example) positional | ||||
| 
     | 
||||
| options: | ||||
| -h, --help show this help message and exit | ||||
| -p {1 (option A), 2 (option B)}, --optional {1 (option A), 2 (option B)} | ||||
| ''' | ||||
| version = '' | ||||
| 
     | 
||||
| 
     | 
||||
| class TestHelpOnlyUserGroups(HelpTestCase): | ||||
| """Test basic usage messages""" | ||||
| 
     | 
||||
| 
          
            
          
           | 
    ||||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix a bug that parentheses in metavar argument of :func:`add_argument()` were | ||
                
      
                  yeojin-dev marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| dropped. Patch by Yeojin Kim. | ||
Uh oh!
There was an error while loading. Please reload this page.