mirror of
https://github.com/esphome/esphome.git
synced 2026-09-26 22:40:21 +00:00
State the cv.boolean alignment at the definition
This commit is contained in:
@@ -395,6 +395,12 @@ def sort_ip_addresses(address_list: list[str]) -> list[str]:
|
||||
|
||||
|
||||
def get_bool_env(var, default=False):
|
||||
"""Read a boolean environment knob.
|
||||
|
||||
Accepts the same spellings as ``cv.boolean`` does in YAML, so the
|
||||
environment speaks the config language's boolean dialect; anything
|
||||
unrecognized falls through to ``bool(value)``.
|
||||
"""
|
||||
value = os.getenv(var, default)
|
||||
if isinstance(value, str):
|
||||
value = value.lower()
|
||||
|
||||
@@ -1124,6 +1124,6 @@ def test_format_duration(seconds: float, expected: str) -> None:
|
||||
def test_get_bool_env_common_spellings(
|
||||
monkeypatch: pytest.MonkeyPatch, value: str, expected: bool
|
||||
) -> None:
|
||||
"""The common on/off spellings parse instead of reading as truthy."""
|
||||
"""The cv.boolean spellings parse instead of reading as truthy."""
|
||||
monkeypatch.setenv("SOME_KNOB", value)
|
||||
assert helpers.get_bool_env("SOME_KNOB") is expected
|
||||
|
||||
Reference in New Issue
Block a user