@@ -27,17 +27,17 @@ def __init__(
27
27
# Non-argparse changes
28
28
assert help , "All BooleanOptionalAction's should have a help message."
29
29
30
- # Rest of implementation directly copied from argparse
30
+ # Rest of implementation directly copied from argparse, expect for the asserts
31
31
_option_strings = []
32
32
for option_string in option_strings :
33
33
_option_strings .append (option_string )
34
34
35
- if option_string .startswith ("--" ):
36
- option_string = "--no-" + option_string [2 :]
37
- _option_strings .append (option_string )
35
+ assert option_string .startswith ("--" )
36
+ option_string = "--no-" + option_string [2 :]
37
+ _option_strings .append (option_string )
38
38
39
- if help is not None and default is not None :
40
- help += " (default: %(default)s)"
39
+ assert help is not None and default is not None
40
+ help += " (default: %(default)s)"
41
41
42
42
super ().__init__ (
43
43
option_strings = _option_strings ,
@@ -63,8 +63,8 @@ def __call__(
63
63
"BooleanOptionalAction can't be a positional argument. "
64
64
f"Something is wrong with { self .option_strings [0 ]} "
65
65
)
66
- if option_string in self .option_strings :
67
- setattr (namespace , self .dest , not option_string .startswith ("--no-" ))
66
+ assert option_string in self .option_strings
67
+ setattr (namespace , self .dest , not option_string .startswith ("--no-" ))
68
68
69
69
def format_usage (self ) -> str :
70
70
"""Return usage string."""
0 commit comments