diff --git a/aws_lambda_powertools/shared/functions.py b/aws_lambda_powertools/shared/functions.py index 24a0bc830a8..11c4e4ce77c 100644 --- a/aws_lambda_powertools/shared/functions.py +++ b/aws_lambda_powertools/shared/functions.py @@ -1,7 +1,7 @@ from typing import Any, Optional, Union -def _strtobool(value: str) -> bool: +def strtobool(value: str) -> bool: """Convert a string representation of truth to True or False. 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 choice : str resolved choice as either bool or environment value """ - return choice if choice is not None else _strtobool(env) + return choice if choice is not None else strtobool(env) def resolve_env_var_choice(env: Any, choice: Optional[Any] = None) -> Union[bool, Any]: diff --git a/tests/functional/test_shared_functions.py b/tests/functional/test_shared_functions.py index db1a672eb37..c71b7239739 100644 --- a/tests/functional/test_shared_functions.py +++ b/tests/functional/test_shared_functions.py @@ -1,6 +1,6 @@ import pytest -from aws_lambda_powertools.shared.functions import _strtobool, resolve_env_var_choice, resolve_truthy_env_var_choice +from aws_lambda_powertools.shared.functions import resolve_env_var_choice, resolve_truthy_env_var_choice, strtobool 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(): @pytest.mark.parametrize("true_value", ["y", "yes", "t", "true", "on", "1"]) def test_strtobool_true(true_value): - assert _strtobool(true_value) + assert strtobool(true_value) @pytest.mark.parametrize("false_value", ["n", "no", "f", "false", "off", "0"]) def test_strtobool_false(false_value): - assert _strtobool(false_value) is False + assert strtobool(false_value) is False def test_strtobool_value_error(): with pytest.raises(ValueError) as exp: - _strtobool("fail") + strtobool("fail") assert str(exp.value) == "invalid truth value 'fail'"