[Python-checkins] Remove redundant if check from optional argument function in argparse. (GH-8766)

Benjamin Peterson webhook-mailer at python.org
Thu Jun 20 23:02:27 EDT 2019


https://github.com/python/cpython/commit/b9600b0fbd71908f9fb3dd1bf78ebba6c4a16115
commit: b9600b0fbd71908f9fb3dd1bf78ebba6c4a16115
branch: master
author: Shashank Parekh <shashank201101193 at gmail.com>
committer: Benjamin Peterson <benjamin at python.org>
date: 2019-06-20T20:02:22-07:00
summary:

Remove redundant if check from optional argument function in argparse. (GH-8766)

files:
M Lib/argparse.py

diff --git a/Lib/argparse.py b/Lib/argparse.py
index 9a67b41ae00e..4f3aea928bf6 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -1479,10 +1479,8 @@ def _get_optional_kwargs(self, *args, **kwargs):
 
             # strings starting with two prefix characters are long options
             option_strings.append(option_string)
-            if option_string[0] in self.prefix_chars:
-                if len(option_string) > 1:
-                    if option_string[1] in self.prefix_chars:
-                        long_option_strings.append(option_string)
+            if len(option_string) > 1 and option_string[1] in self.prefix_chars:
+                long_option_strings.append(option_string)
 
         # infer destination, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
         dest = kwargs.pop('dest', None)



More information about the Python-checkins mailing list