Skip to content

Commit 01a0fa5

Browse files
committed
Show appropriate error message
This catches code exception if wrong arguments passed to cmd options It also adds error message that suggests correct arguments to pass Fixes: #5616
1 parent a296897 commit 01a0fa5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

news/5644.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Show appropriate error message if invalid args passed

src/pip/_internal/baseparser.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,17 @@ def _update_defaults(self, defaults):
192192
continue
193193

194194
if option.action in ('store_true', 'store_false', 'count'):
195-
val = strtobool(val)
195+
try:
196+
val = strtobool(val)
197+
except ValueError:
198+
self.error(
199+
"#{0} is not a valid value. Valid true values"
200+
"are {1}, {2}, {3}, {4} and valid false values"
201+
"are {5}, {6}, {7}, {8}".format(
202+
val, "true", "yes", "on", 1,
203+
"false", "no", "off", 0
204+
)
205+
)
196206
elif option.action == 'append':
197207
val = val.split()
198208
val = [self.check_default(option, key, v) for v in val]

0 commit comments

Comments
 (0)