Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions awswrangler/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ 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}."
)
if isinstance(value, str) and dtype is bool:
return _Config._cast_bool(name=name, value=value.lower())
try:
return dtype(value) if isinstance(value, dtype) is False else value
except ValueError as ex:
Expand All @@ -239,6 +241,14 @@ def _is_null(value: _ConfigValueType | None) -> bool:
return True
return False

@staticmethod
def _cast_bool(name: str, value: str) -> bool:
_true = ("true", "1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to think about what is currently "truthy" according to L230 and keep it backward-compatible

_false = ("false", "0", "")
if value not in _true + _false:
raise exceptions.InvalidArgumentValue(f"{name} configuration only accepts True/False or 0/1.")
return value in _true

@property
def catalog_id(self) -> str | None:
"""Property catalog_id."""
Expand Down