cliguard 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -91,6 +91,19 @@ def main():
|
|
|
91
91
|
except TypeError:
|
|
92
92
|
return None
|
|
93
93
|
|
|
94
|
+
def resolve_default(p):
|
|
95
|
+
# A flag's own default across Click versions is either a plain
|
|
96
|
+
# bool (older/most versions: False when unset) or an internal
|
|
97
|
+
# not-JSON-serializable sentinel (newer versions, when no
|
|
98
|
+
# default= was passed) - caught live via CI running a different
|
|
99
|
+
# pip-installed Click version than local testing used. Either
|
|
100
|
+
# way the real, version-stable answer for "what value does the
|
|
101
|
+
# caller get if they never pass this flag" is False, unless an
|
|
102
|
+
# explicit bool default (e.g. default=True) was actually set.
|
|
103
|
+
if p.is_flag and not isinstance(p.default, bool):
|
|
104
|
+
return False
|
|
105
|
+
return safe_default(p.default)
|
|
106
|
+
|
|
94
107
|
def dump_param(p):
|
|
95
108
|
if isinstance(p, click.Argument):
|
|
96
109
|
return {
|
|
@@ -107,7 +120,7 @@ def main():
|
|
|
107
120
|
"required": bool(p.required),
|
|
108
121
|
"is_flag": bool(p.is_flag),
|
|
109
122
|
"multiple": bool(p.multiple),
|
|
110
|
-
"default":
|
|
123
|
+
"default": resolve_default(p),
|
|
111
124
|
"help": p.help,
|
|
112
125
|
}
|
|
113
126
|
|