Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b9600b0

Browse filesBrowse files
sp1rsbenjaminp
authored andcommitted
Remove redundant if check from optional argument function in argparse. (GH-8766)
1 parent 1e61504 commit b9600b0
Copy full SHA for b9600b0

File tree

Expand file treeCollapse file tree

1 file changed

+2
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-4
lines changed

‎Lib/argparse.py

Copy file name to clipboardExpand all lines: Lib/argparse.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,10 +1479,8 @@ def _get_optional_kwargs(self, *args, **kwargs):
14791479

14801480
# strings starting with two prefix characters are long options
14811481
option_strings.append(option_string)
1482-
if option_string[0] in self.prefix_chars:
1483-
if len(option_string) > 1:
1484-
if option_string[1] in self.prefix_chars:
1485-
long_option_strings.append(option_string)
1482+
if len(option_string) > 1 and option_string[1] in self.prefix_chars:
1483+
long_option_strings.append(option_string)
14861484

14871485
# infer destination, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
14881486
dest = kwargs.pop('dest', None)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.