Skip to content

Commit

Permalink
fix: handle case of str to bool env variable in config (#2966)
Browse files Browse the repository at this point in the history
* fix: handle case of str to bool env variable in config

* fix: add missing empty case

* fix: PR feedback

* not in
  • Loading branch information
jaidisido authored Oct 2, 2024
1 parent 635f6d5 commit 5c6d3be
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions awswrangler/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ def _apply_type(name: str, value: Any, dtype: type[_ConfigValueType], nullable:
raise exceptions.InvalidArgumentValue(
f"{name} configuration does not accept a null value. Please pass {dtype}."
)
# Handle case where string is empty, "False" or "0". Anything else is True
if isinstance(value, str) and dtype is bool:
return value.lower() not in ("false", "0", "")
try:
return dtype(value) if isinstance(value, dtype) is False else value
except ValueError as ex:
Expand Down

0 comments on commit 5c6d3be

Please sign in to comment.