Skip to content

Commit d49d1bd

Browse files
committed
Add some asserts for things that are always true
1 parent 78b5158 commit d49d1bd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pydocstringformatter/_configuration/boolean_option_action.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ def __init__(
2727
# Non-argparse changes
2828
assert help, "All BooleanOptionalAction's should have a help message."
2929

30-
# Rest of implementation directly copied from argparse
30+
# Rest of implementation directly copied from argparse, expect for the asserts
3131
_option_strings = []
3232
for option_string in option_strings:
3333
_option_strings.append(option_string)
3434

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

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)"
4141

4242
super().__init__(
4343
option_strings=_option_strings,
@@ -63,8 +63,8 @@ def __call__(
6363
"BooleanOptionalAction can't be a positional argument. "
6464
f"Something is wrong with {self.option_strings[0]}"
6565
)
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-"))
6868

6969
def format_usage(self) -> str:
7070
"""Return usage string."""

0 commit comments

Comments
 (0)