Skip to content

Commit

Permalink
refactor: revert name back to strtobool
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Brewer committed Dec 29, 2021
1 parent 36cb9e9 commit f5685d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions aws_lambda_powertools/shared/functions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]:
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/test_shared_functions.py
Original file line number Diff line number Diff line change
@@ -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():
Expand All @@ -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'"

0 comments on commit f5685d0

Please sign in to comment.