Skip to content

Commit 6049784

Browse files
authored
fix default value set for bool type (#273)
1 parent 11f2454 commit 6049784

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

knack/commands.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ def update_argument(self, param_name, argtype):
124124
# that coincides with the default
125125
if isinstance(arg_default, str):
126126
arg_default = DefaultStr(arg_default)
127-
elif isinstance(arg_default, int):
127+
elif isinstance(arg_default, int) and not isinstance(arg_default, bool):
128+
# bool's is_default is ignored for now, because
129+
# 1. bool is a subclass of int, so isinstance(True, int) cannot distinguish between int and bool
130+
# 2. bool is not extendable according to https://stackoverflow.com/a/2172204/2199657
128131
arg_default = DefaultInt(arg_default)
129132
# update the default
130133
if arg_default:

0 commit comments

Comments
 (0)