Skip to content

Commit b9600b0

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

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Lib/argparse.py

Lines 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)