Skip to content

Commit 6c4c2f5

Browse files
authored
Merge pull request #676 from AnswerDotAI/bool_type_warn
Add warning callout re: bool and store_true defaults
2 parents e1db8d5 + f62832e commit 6c4c2f5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

nbs/06_script.ipynb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@
9292
"You should provide a default (after the `=`) for any *optional* parameters. If you don't provide a default for a parameter, then it will be a *positional* parameter."
9393
]
9494
},
95+
{
96+
"cell_type": "markdown",
97+
"metadata": {},
98+
"source": [
99+
"::: {.callout-warning}\n",
100+
"## Boolean Arguments Default to False\n",
101+
"Arguments of type `bool` or `store_true` default to `False` regardless of whether you provide a default or not. Use `bool_arg` as the type instead of `bool` if you want to set a default value of True. For example:\n",
102+
"\n",
103+
"```python\n",
104+
"@call_parse\n",
105+
"def main(msg:str=\"Hi\", # The message\n",
106+
" upper:bool_arg=True): # Convert to uppercase?\n",
107+
"```\n",
108+
":::"
109+
]
110+
},
95111
{
96112
"cell_type": "markdown",
97113
"metadata": {},

0 commit comments

Comments
 (0)