Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion guide/content/en/guide/running/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ When loading from environment variables, Sanic will attempt to cast the values t
In regards to `bool`, the following _case insensitive_ values are allowed:

- **`True`**: `y`, `yes`, `yep`, `yup`, `t`, `true`, `on`, `enable`, `enabled`, `1`
- **`False`**: `n`, `no`, `f`, `false`, `off`, `disable`, `disabled`, `0`
- **`False`**: `n`, `no`, `f`, `nope`, `false`, `off`, `disable`, `disabled`, `0`

If a value cannot be cast, it will default to a `str`.

Expand Down
6 changes: 4 additions & 2 deletions sanic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def str_to_bool(val: str) -> bool:
"true", "on", "enable", "enabled", "1"
) returns True.
If val is in case insensitive (
"n", "no", "f", "false", "off", "disable", "disabled", "0"
"n", "no", "f", "nope", "false", "off", "disable", "disabled", "0"
) returns False.
Else Raise ValueError."""

Expand All @@ -36,7 +36,9 @@ def str_to_bool(val: str) -> bool:
"1",
}:
return True
elif val in {"n", "no", "f", "false", "off", "disable", "disabled", "0"}:
elif val in {
"n", "no", "f", "nope", "false", "off", "disable", "disabled", "0"
}:
return False
else:
raise ValueError(f"Invalid truth value {val}")
Expand Down
12 changes: 11 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@ def str_to_bool(val: str) -> bool:
"1",
}:
return True
elif val in {"n", "no", "f", "false", "off", "disable", "disabled", "0"}:
elif val in {
"n",
"no",
"f",
"nope",
"false",
"off",
"disable",
"disabled",
"0",
}:
return False
else:
raise ValueError(f"Invalid truth value {val}")
Expand Down
Loading