Skip to content

Commit f5685d0

Browse files
author
Michael Brewer
committed
refactor: revert name back to strtobool
1 parent 36cb9e9 commit f5685d0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Diff for: aws_lambda_powertools/shared/functions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Any, Optional, Union
22

33

4-
def _strtobool(value: str) -> bool:
4+
def strtobool(value: str) -> bool:
55
"""Convert a string representation of truth to True or False.
66
77
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
@@ -35,7 +35,7 @@ def resolve_truthy_env_var_choice(env: str, choice: Optional[bool] = None) -> bo
3535
choice : str
3636
resolved choice as either bool or environment value
3737
"""
38-
return choice if choice is not None else _strtobool(env)
38+
return choice if choice is not None else strtobool(env)
3939

4040

4141
def resolve_env_var_choice(env: Any, choice: Optional[Any] = None) -> Union[bool, Any]:

Diff for: tests/functional/test_shared_functions.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from aws_lambda_powertools.shared.functions import _strtobool, resolve_env_var_choice, resolve_truthy_env_var_choice
3+
from aws_lambda_powertools.shared.functions import resolve_env_var_choice, resolve_truthy_env_var_choice, strtobool
44

55

66
def test_resolve_env_var_choice_explicit_wins_over_env_var():
@@ -15,15 +15,15 @@ def test_resolve_env_var_choice_env_wins_over_absent_explicit():
1515

1616
@pytest.mark.parametrize("true_value", ["y", "yes", "t", "true", "on", "1"])
1717
def test_strtobool_true(true_value):
18-
assert _strtobool(true_value)
18+
assert strtobool(true_value)
1919

2020

2121
@pytest.mark.parametrize("false_value", ["n", "no", "f", "false", "off", "0"])
2222
def test_strtobool_false(false_value):
23-
assert _strtobool(false_value) is False
23+
assert strtobool(false_value) is False
2424

2525

2626
def test_strtobool_value_error():
2727
with pytest.raises(ValueError) as exp:
28-
_strtobool("fail")
28+
strtobool("fail")
2929
assert str(exp.value) == "invalid truth value 'fail'"

0 commit comments

Comments
 (0)